Reputation: 43
I have a table that is similar to the one below. As you can see, I have stored the dates as Unix timestamps. My goal is to only return the results which are for the upcoming dates, not the ones which are in past. How can I achieve this?
id | date
1 1331506800 //Mar 12 2012
2 1366149600 //Apr 17 2013
3 1413928800 //Oct 22 2014
4 1436652000 //Jul 12 2015
Desire result:
id | date
1 1413928800 //Oct 22 2014
2 1436652000 //Jul 12 2015
Upvotes: 0
Views: 889
Reputation: 24937
$h->query("SELECT * FROM thetable WHERE date > " . time());
This will also work in other databases than MySQL which do not have UNIX_TIMESTAMP() function.
Upvotes: 1
Reputation: 13465
Try this::
Select * from table
where DATEDIFF(STR_TO_DATE(dateColumn, '%e %b %Y %k:%i')),now())>0
Upvotes: 0