mysql compare 2 dates code example

Example 1: mysql compare datetime to another datetime

Select * From temp where mydate > STR_TO_DATE('2009-06-29 04:00:44', '%Y-%m-%d %H:%i:%s');

Example 2: mysql compare datetime to another datetime

Select * From temp where mydate > '2009-06-29 04:00:44';

Example 3: compare date mysql

SELECT *
FROM players
WHERE DATE(us_reg_date) BETWEEN '2000-07-05' AND '2011-11-10'

Example 4: mysql query dates between two dates

select * from users 
where signup_date between '2020-05-01' and '2020-12-10 23:59:59';
// Important with the times, 
// otherwize you will not get all records from end date.
// Event if you only have date and no times in signup_date column

Tags:

Sql Example