定时器间隔后选择数据 [英] select data after timer interval

查看:93
本文介绍了定时器间隔后选择数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,请帮助


i从早上8点到晚上8点有数据表,如车速,位置等


我需要获得这些细节,但每15分钟后

即在上午8点选择数据后,它选择数据@上午8点15分然后上午8点30分


hw can我为此写了一个mysql查询?或者欣赏PHP方法

解决方案

这取决于你如何存储数据。如果它是一个日期时间字段,你可以获取分钟数,将它修改为15,如果它等于0,则返回该行。


如果你的日期有这个格式([4位数年份] - [2位数月份] - [2位数日期] [2位数小时]:[2位数分钟]:[2位数秒])


例如

1982-01-03 13:12:30


在这种情况下你可以简单比较一下你的查询


如(从event_recorder中选择some_events,其中时间介于''1982-01-03 13:12:30''和''1982-01-03 13:27:30'')


我不确定它是否与其他格式不同。


但是在mysql中你将获得以上格式。


和php使用函数mktime来做你的数学时间


Rabbit ,感谢您的回复。 cd u plz format ur回复查询。它将是一个很大的帮助

johny10151981 ,日期是格式1982-01-03 13:12:30,但是你的查询返回两次之间的细节,但我们需要在每15分钟后获取这些详细信息

即在上午8点选择数据后查询shd选择数据@上午8点15分然后上午8点30分


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

解决方案

It depends on how you''re storing the data. If it''s as a date time field, you can grab the number of minutes, mod it by 15, and if it equal 0, return that row.


if your date has this format ([4 digit year]-[2 digit month]-[2 digit date] [2 digit hour]:[2 digit minute]:[2 digit seconds])

e.g
1982-01-03 13:12:30

in that case you can get do your query simple comparison way

such as (SELECT some_events from event_recorder where time between ''1982-01-03 13:12:30'' and ''1982-01-03 13:27:30'')

I am not sure whether it would be different in other format or not.

but in mysql you will get in above format.

and in php use the function mktime to do your time math


Rabbit, thanks for the reply. cd u plz format ur reply into a query. It wd be a great help

johny10151981,date is the format 1982-01-03 13:12:30, but ur query returns the details between two time, but we need to get these details after every 15 minutes
i.e. after selecting datas at 8 a.m. query shd select datas @ 8.15 a.m. then 8.30 a.m.


这篇关于定时器间隔后选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆