开发者

select all events within the next hour

开发者 https://www.devze.com 2023-01-05 09:14 出处:网络
In my MySQL database, there is a table, where I store daily rec开发者_JAVA百科urring events. I store the time of the event in the field time, that has the \'TIME\' type. How do I select all events w

In my MySQL database, there is a table, where I store daily rec开发者_JAVA百科urring events.

I store the time of the event in the field time, that has the 'TIME' type. How do I select all events within the next hour?


Try this:

SELECT *
FROM your_table
WHERE TIMEDIFF(`time`,TIME(NOW())) < TIME('01:00:00');


Something like this:

TIMEDIFF(event.time, TIME(NOW())) < TIME('01:00:00')

See MySQL date/time functions.

0

精彩评论

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