Reputation: 31
I am stuck with this issue for a while now any solutions are welcomed.
I have a table in MySQL and i am storing a timestamp
.
Now lets say if i search on the basis of only date it works.
SELECT *
FROM table
WHERE timestamp > "2012-03-12";
this fetches all data where timestamp value is greater than 2012-03-12 00:00:00.
what i want is a query like this :
SELECT *
FROM table
WHERE timestamp > "10:20:09";
where all records with tie greater than 10:20:09 is fetched irrespective of the date.
Upvotes: 1
Views: 3706
Reputation: 1936
Use this statement (it will get the time from your datetime column and compare it with the time)
SELECT *
FROM table
WHERE DATE_FORMAT(yourDatecolumn, '%H:%i:s') > '10:20:00'
Warning This time format is for EU times (where 1pm = 13), if you want US format, use '%h:%i:s'
Upvotes: 6