Have you ever missed records while filtering dates in SQL?
Imagine your manager asks you to prepare a report showing all orders placed on 7 November 2026.
Your "orders" table contains both dates and timestamps, such as "2026-11-07 14:30:00".
You decide to use BETWEEN to filter the records.
But will your query return all orders placed on that day?
Let's look at the data.
orders
order_id order_date amount
101 2026-11-07 09:30:00 5000
102 2026-11-07 14:45:00 3000
103 2026-11-07 22:15:00 7000
104 2026-11-08 08:00:00 4000
Your Challenge
Write an SQL query to:
Retrieve all orders placed on 7 November 2026.
Include orders placed at any time during that day.
Exclude orders placed on 8 November 2026.
Use a date range condition to filter the records.
Think before you scroll!
The SQL Solution
SELECT
order_id,
order_date,
amount
FROM orders
WHERE order_date >= '2026-11-07'
AND order_date < '2026-11-08';
Expected Output
order_id order_date amount
101 2026-11-07 09:30:00 5000
102 2026-11-07…