t_machine Posted October 12, 2008 Share Posted October 12, 2008 Hi, I have a database that stores data each day using the time() function. How can I run a query to get results from the previous week. Example: Table -> id, name, date_added( time() ) How can I select all names from 1 week ago. Thanks for any help Link to comment https://forums.phpfreaks.com/topic/128112-how-to-get-last-week-result-from-unixtimestamp/ Share on other sites More sharing options...
genericnumber1 Posted October 12, 2008 Share Posted October 12, 2008 If it's stored as linux timestamps you could select all times > the value from the php function strtotime('-1 week'); Link to comment https://forums.phpfreaks.com/topic/128112-how-to-get-last-week-result-from-unixtimestamp/#findComment-663452 Share on other sites More sharing options...
taith Posted October 12, 2008 Share Posted October 12, 2008 $t=strtotime("NOW - 1 week"); mysql_query("SELECT * FROM `` WHERE `date_added`>'$t'"); Link to comment https://forums.phpfreaks.com/topic/128112-how-to-get-last-week-result-from-unixtimestamp/#findComment-663453 Share on other sites More sharing options...
Barand Posted October 12, 2008 Share Posted October 12, 2008 SELECT * FROM tablename WHERE FROM_UNIXTIME(date_added) > CURDATE() - INTERVAL 7 DAY Link to comment https://forums.phpfreaks.com/topic/128112-how-to-get-last-week-result-from-unixtimestamp/#findComment-663476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.