MYSQL query between two timestamps
I have the following entry in my DB table
eventName(varchar 100) -> myEvent
date(timestamp) -> 2013-03-26 09:00:00
and I am trying to use the following query;
SELECT *
FROM eventList
WHERE `date` BETWEEN UNIX_TIMESTAMP(1364256001) AND UNIX_TIMESTAMP(1364342399)
i.e between 2013-03-26 00:00:01 and 2013-03-26 23:59:59
but it is giving me 0 results.
I have tried expanding the date range with no luck and there are definitely results within the range.
any help is appreciated.
Solution 1:
Try:
SELECT *
FROM eventList
WHERE `date` BETWEEN FROM_UNIXTIME(1364256001) AND FROM_UNIXTIME(1364342399)
Or
SELECT *
FROM eventList WHERE `date`
BETWEEN '2013-03-26 00:00:01' AND '2013-03-26 23:59:59'
Solution 2:
Try this one. It works for me.
SELECT * FROM eventList
WHERE DATE(date)
BETWEEN
'2013-03-26'
AND
'2013-03-27'