Suppose you get a chance to write a DATE comparison in the WHERE clause. Here’re brilliant ideas on how to use it in the WHERE clause for your quick reference.
For this demo, I chose three examples. This logic you can follow for comparing the DATEs in your project.
SQL Query Compares Dates using ‘>’ Greater than
SELECT *
FROM table
WHERE purchdate > '2002-10-01';
The syntax for DATE is
datecolumn > ‘XXXX-XX-XX’
- Always you need to give date in quotes.
- You can use <, >, = in DATE comparisons.
SQL Query Compare Dates using ‘<‘ Less than
SELECT *
FROM table
WHERE purchdate < '2002-10-10';
SQL Query Using DATE ‘=’ Equal to
SELECT *
FROM table
WHERE purchdate = '2020-04-19;
-
Recent posts
How to Use Filter() on List in Python
Helpful python filter() examples that show you the usage of it on lists to filter out the True values.
-
Recent posts
JCL MSGCLASS Vs. MSGLEVEL Top Differences
The MSGCLASS and MSGLEVEL control the print of messages to the output listing. Here are the detailed meanings and default values.
-
Recent posts
20 Software Engineer Gift Ideas: From Gadgets to Games
Here are the top gift ideas for software developers that you can buy online for their marriages, birthdays, and other special occasions.
Related