开发者

select query for time interval in mysql and php

开发者 https://www.devze.com 2023-01-06 14:53 出处:网络
select query to select all records that were inserted in 15 minutes.for ex if now time is 10:00 then it shoulld fetch all record in开发者_如何学JAVAserted from 9:45 to 10:00Assuming you have a DATETIM

select query to select all records that were inserted in 15 minutes.for ex if now time is 10:00 then it shoulld fetch all record in开发者_如何学JAVAserted from 9:45 to 10:00


Assuming you have a DATETIME column named created in your table:

SELECT id FROM tablename 
WHERE ((created > DATE_SUB(NOW(), INTERVAL 15 MINUTE))
  AND (created < NOW()))


select * from table WHERE datetimeField BETWEEN date_add(NOW(),INTERVAL -15 MINUTE) AND NOW();
0

精彩评论

暂无评论...
验证码 换一张
取 消