How to compare date in SQL?

Posted on In QA, Tutorial

How to compare date in SQL? For example, the ‘users’ table has a column ‘loggin’ which is the date and time. How to find out the ‘users’ whose ‘loggin’ date is later than Jan 10, 2017?

In SQL, dates can be compared using ‘<‘, ‘>’, ‘<=‘ and ‘>=‘.

For the example described, the SQL statement could be:

SELECT *
FROM users
WHERE login > ‘2017-01-10’

Related references as follows.

For the date string https://en.m.wikipedia.org/wiki/ISO_8601

Leave a Reply

Your email address will not be published. Required fields are marked *