Select mysql query between date?
Solution 1:
select * from *table_name* where *datetime_column* between '01/01/2009' and curdate()
or using >=
and <=
:
select * from *table_name* where *datetime_column* >= '01/01/2009' and *datetime_column* <= curdate()
Solution 2:
All the above works, and here is another way if you just want to number of days/time back rather a entering date
select * from *table_name* where *datetime_column* BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()
Solution 3:
You can use now()
like:
Select data from tablename where datetime >= "01-01-2009 00:00:00" and datetime <= now();