问题
My each row have time-stamp column (called 'timestamp'). How can I find all rows from specific day?
I've tried calculating start/end of the day, but i'm looking for a better way.
回答1:
You need to extract just the date part, using DATE() function:
SELECT *
FROM yourtable
WHERE DATE(your_column) = '2013-07-03'
or you can use this, that can make use of an index:
SELECT *
FROM yourtable
WHERE your_column >= '2013-07-03' AND
your_column < '2013-07-03' + INTERVAL 1 DAY
回答2:
use the date function:
select date('2013-07-03 15:58:37');
来源:https://stackoverflow.com/questions/17449920/mysql-find-entries-from-specific-day-using-timestamp-column