sandy1028 Posted September 14, 2007 Share Posted September 14, 2007 Hi, The query select * from tablename where timestamp < now() and timestamp > (now()-interval 1 day) fetches all the day for one day. How to get the values for each ten min interval data for the one day. Link to comment https://forums.phpfreaks.com/topic/69300-regarding-query/ Share on other sites More sharing options...
bonaparte Posted September 14, 2007 Share Posted September 14, 2007 Sorry, I did not understand the SQL. What exactly do you mean by "fetches all the day for one day"? What is "interval 1 day"? Link to comment https://forums.phpfreaks.com/topic/69300-regarding-query/#findComment-348230 Share on other sites More sharing options...
sandy1028 Posted September 14, 2007 Author Share Posted September 14, 2007 Hi, The query select * from tablename where timestamp < now() and timestamp > (now()-interval 1 day) fetches all the day for one day. How to calculate the average of each timestamp of ten minutes in the above query Link to comment https://forums.phpfreaks.com/topic/69300-regarding-query/#findComment-348235 Share on other sites More sharing options...
redarrow Posted September 14, 2007 Share Posted September 14, 2007 trie this mate. should show every 10 min entry <?php $query="select * from tablename where timestamp < now() and timestamp > (now()-interval 1 day) and timestamp = DATE_SUB('.$timestamp.',INTERVAL '23:50:0' MINUTE_SECOND)"; ?> not sure here but it should off been <?php $query="select * from tablename where timestamp < now() and timestamp > DATE_SUB(now() interval 1 day) and timestamp = DATE_SUB('.$timestamp.',INTERVAL '23:50:0' MINUTE_SECOND)"; ?> Link to comment https://forums.phpfreaks.com/topic/69300-regarding-query/#findComment-348237 Share on other sites More sharing options...
sandy1028 Posted September 14, 2007 Author Share Posted September 14, 2007 Can u please suggest me a query which uses time() instead of now(). The ten minutes data to be fetched vary in seconds. While calculating averge the value got is NULL select `fieldname` from `tablename` where `timestamp` < time() and timestamp > (time()-interval 1 day) This I tried but not working Link to comment https://forums.phpfreaks.com/topic/69300-regarding-query/#findComment-348246 Share on other sites More sharing options...
redarrow Posted September 14, 2007 Share Posted September 14, 2007 look i am trying to work this out now on mysql website you look aswell http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_time Link to comment https://forums.phpfreaks.com/topic/69300-regarding-query/#findComment-348252 Share on other sites More sharing options...
redarrow Posted September 14, 2007 Share Posted September 14, 2007 try that <?php $query="select * from tablename where timestamp < now() and timestamp > (now()-interval 1 day) and timestamp = ('.$timestamp.',- INTERVAL '85800')"; ?> Link to comment https://forums.phpfreaks.com/topic/69300-regarding-query/#findComment-348258 Share on other sites More sharing options...
redarrow Posted September 14, 2007 Share Posted September 14, 2007 try this as well <?php $query="select * from tablename where timestamp = ('.$timestamp.',- INTERVAL '85800')"; ?> Link to comment https://forums.phpfreaks.com/topic/69300-regarding-query/#findComment-348262 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.