sandy1028 Posted September 12, 2007 Share Posted September 12, 2007 Hi, Please help me how to write the query to fetch the data from current timestamp to last 24hours from the table Quote Link to comment https://forums.phpfreaks.com/topic/69005-query/ Share on other sites More sharing options...
phat_hip_prog Posted September 12, 2007 Share Posted September 12, 2007 I'm supposing this is mysql, and that you have a timestamp (pref in some form of julian time (seconds)), then anything greater than now-(24*3600) is in last 24hrs Quote Link to comment https://forums.phpfreaks.com/topic/69005-query/#findComment-346851 Share on other sites More sharing options...
ToonMariner Posted September 12, 2007 Share Posted September 12, 2007 assuming you store a time stamp then... $qry = "SELECT * FROM `tablename` WHERE `timestamp` > " . time() - (3600 * 24); $qry = mysql_query($qry); if you actually store a date... $qry = "SELECT * FROM `tablename` WHERE `date` > DATESUB(NOW(), INTERVAL 1 DAY)"; $qry = mysql_query($qry); Quote Link to comment https://forums.phpfreaks.com/topic/69005-query/#findComment-346852 Share on other sites More sharing options...
sandy1028 Posted September 12, 2007 Author Share Posted September 12, 2007 Hi, Thanks for the reply... I am storing timestamp values select * FROM `net_performance` WHERE `timestamp` > " . now() - (3600 * 24) I am confused whether it is time() or now(). Tell me which to use Quote Link to comment https://forums.phpfreaks.com/topic/69005-query/#findComment-346881 Share on other sites More sharing options...
sandy1028 Posted September 12, 2007 Author Share Posted September 12, 2007 When I use select * from `tablename` WHERE `timestamp` > " . now() - (3600 * 24); all the values are displayed. How to get the values only for 24 hrs Quote Link to comment https://forums.phpfreaks.com/topic/69005-query/#findComment-346887 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.