将 12 小时添加到 mysql 当前时间戳
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8070765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
adding 12 hours to mysql current timestamp
提问by Denoteone
I am trying to filter my query data to only return items where "Meeting Start"
is greater than CURRENT_TIMESTAMP
butnot later than 12 hours from the CURRENT_TIMESTAMP.
我试图过滤我的查询数据以仅返回"Meeting Start"
大于CURRENT_TIMESTAMP
但不迟于 CURRENT_TIMESTAMP 12 小时的项目。
Can I add 12 hours to the CURRENT_TIMESTAMP inline below in my query?
我可以在查询中的下方内联 CURRENT_TIMESTAMP 中添加 12 小时吗?
Current Working Query:
当前工作查询:
$query ="SELECT * FROM Reservations WHERE [Room_ID] = '$field' AND [Meeting Start] > CURRENT_TIMESTAMP ORDER BY [Meeting Start] asc ";
Updated Try:
更新尝试:
$query ="SELECT * FROM Reservations WHERE [Room_ID] = '$field' AND [Meeting Start] > CURRENT_TIMESTAMP AND [Meeting Start] < (CURRENT_TIMESTAMP + 12) ORDER BY [Meeting Start] asc ";
回答by Marc B
NOW() + INTERVAL 12 HOUR
should do the trick. +12
is ambiguous. 12 seconds? minutes? days? years?
NOW() + INTERVAL 12 HOUR
应该做的伎俩。+12
是模棱两可的。12秒?分钟?天?年?