SQL
Filter Records by a Specific Date Range
Learn to retrieve database records that fall within a precise date or datetime range using SQL's WHERE clause and comparison operators.
SELECT order_id, customer_name, order_date, total_amount
FROM orders
WHERE order_date BETWEEN '2023-01-01' AND '2023-01-31';
How it works: This query selects all orders placed within January 2023. The `BETWEEN` operator is inclusive, meaning it includes records where `order_date` is exactly '2023-01-01' and '2023-01-31'. This is a common requirement for generating reports or displaying historical data based on specific periods.