Selecting different time periods from SQL Query
Posted: Mon Aug 09, 2010 4:16 am
Hello,
I have the following query:
The photos table contains one column called "dateposted' which is in the following format (2010-08-03 00:15:00).
How do I from this query select different timeframes by using "hours" something like this I am guessing??:
Thanks so much. /df
I have the following query:
Code: Select all
$sql = "Select photos.*, categories.cat FROM photos, categories
WHERE photos.cat_id = categories.id AND photos.status ='1' ORDER BY (videos.up-videos.down) DESC
LIMIT $start, $limit";
$result = mysql_query($sql);How do I from this query select different timeframes by using "hours" something like this I am guessing??:
Code: Select all
Day
WHERE dateposted=time(now)-24(hours)
Week
WHERE dateposted=time(now)-168(hours)
Month
WHERE dateposted=time(now)-744(hours)
Year
WHERE dateposted=time(now)-8760(hours)