charles07 Posted April 4, 2012 Share Posted April 4, 2012 guys, plz help i have table with datas like speed of vehicle, position e.t.c from morning 8 a.m. to 8 p.m. I need to get these details, but after every 15 minutes i.e. after selecting datas at 8 a.m. it shd select datas @ 8.15 a.m. then 8.30 a.m. hw can i write a mysql query for this ? or a PHP approach is appreciated Quote Link to comment https://forums.phpfreaks.com/topic/260335-mysql-select-datas-after-time-interval/ Share on other sites More sharing options...
AyKay47 Posted April 4, 2012 Share Posted April 4, 2012 Are you using a date/datetime field to store the date in your db table? Quote Link to comment https://forums.phpfreaks.com/topic/260335-mysql-select-datas-after-time-interval/#findComment-1334304 Share on other sites More sharing options...
charles07 Posted April 9, 2012 Author Share Posted April 9, 2012 yes AYKay47, it's in the time stamp format Quote Link to comment https://forums.phpfreaks.com/topic/260335-mysql-select-datas-after-time-interval/#findComment-1335534 Share on other sites More sharing options...
dcro2 Posted April 9, 2012 Share Posted April 9, 2012 You can't really schedule queries to happen with just php or mysql. Use cron. http://www.htmlcenter.com/blog/running-php-scripts-with-cron/ */15 8-20 * * * php /path/to/php/file.php It all depends on what host you're on, if you have cPanel, etc. Quote Link to comment https://forums.phpfreaks.com/topic/260335-mysql-select-datas-after-time-interval/#findComment-1335629 Share on other sites More sharing options...
AyKay47 Posted April 9, 2012 Share Posted April 9, 2012 In your query you will compare the timestamp field to NOW() Quote Link to comment https://forums.phpfreaks.com/topic/260335-mysql-select-datas-after-time-interval/#findComment-1335630 Share on other sites More sharing options...
charles07 Posted April 10, 2012 Author Share Posted April 10, 2012 thanks dcro2 i was looking cron job tutorial for the same cause, but couldn't find a good one. that link is helpfull. AyKay47, cd u plz explain a bit, a sample query would be highly helpful thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/260335-mysql-select-datas-after-time-interval/#findComment-1335949 Share on other sites More sharing options...
AyKay47 Posted April 10, 2012 Share Posted April 10, 2012 select col_name from tbl_name where timestamp_field = NOW() Quote Link to comment https://forums.phpfreaks.com/topic/260335-mysql-select-datas-after-time-interval/#findComment-1336029 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.