From the course: SQL Server Fundamentals: Master Basic Query Techniques

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Solution: Filtering dates

Solution: Filtering dates

(upbeat music) - [Instructor] To find all of the paid orders from 2023, I'm going to start by selecting all of the columns from the Order table that I care about for this query, the order ID, the creation date, and the status. And then I'm going to start filtering. So I know I have two pieces of information to consider, the status of the order and the creation date of the order. So I'm going to start by filtering with a WHERE condition, where the status column equals paid. And I also need to know that the creation date, now there are two ways to do this. I'll show you both ways. We can use the between operator between 2023-12-01 and 2024-01-01. And if I test my code, we have success. And I just want to point out one thing that might trip you up. The creation date is a date and a time. So when you use this between operator, if I changed this to 2023-12-31, because we see we do have an entry from that date, if we run this, test my code again, I'm actually missing that value because when…

Contents