Select data based on date and time columns
Posted: Sat Feb 12, 2011 12:22 pm
Hi,
I have a mysql db with a date column (yyyy-mm-dd) and a time column (hh:mm:ss) from which I extract data from that falls after todays date...
This works fine however I would to stop like to stop displaying the data based on the time also. i.e. I dont want the rows to drop off at midnight I would like them to drop off at a certain time. Like 3 hrs before the time listed in 'show_time' column.
I tried a workaround but even that is not ideal... and it doesnt work anyway...
I thought this might be 1 hr after midnight but it takes 1 hr after the curent time so that doesnt work either.
Any ideas...
I have a mysql db with a date column (yyyy-mm-dd) and a time column (hh:mm:ss) from which I extract data from that falls after todays date...
Code: Select all
$query="SELECT *
FROM listings
WHERE show_date > CURDATE()
ORDER BY show_date";
$result=mysql_query($query);
$num=mysql_numrows($result);I tried a workaround but even that is not ideal... and it doesnt work anyway...
Code: Select all
$query="SELECT *
FROM listings
WHERE show_date > DATE_SUB(CURDATE(), INTERVAL 1 HOUR)
ORDER BY show_date";
$result=mysql_query($query);
$num=mysql_numrows($result);I thought this might be 1 hr after midnight but it takes 1 hr after the curent time so that doesnt work either.
Any ideas...