[英]Fetch a data if the time duration between added date and current date is not greater than or equal to 2 hours
I am creating a booking management system.我正在创建一个预订管理系统。 I got stuck in the booking cancellation part.
我被困在预订取消部分。 I want to allow users to cancel their orders if their booking time and the current time duration is between 2 hours because I want to restrict the users to cancel their booking if their booking time and current time duration is greater than or equal to 2 hours.
如果用户的预订时间和当前持续时间在 2 小时之间,我想允许用户取消他们的订单,因为我想限制用户在他们的预订时间和当前持续时间大于或等于 2 小时时取消他们的预订。
I want to generate a query that returns all the bookings whose booking time is less than 2 hours.我想生成一个查询,返回所有预订时间少于 2 小时的预订。 How can I achieve this?
我怎样才能做到这一点?
SELECT * FROM `TableName` where TIMEDIFF(NOW(),Your_date_ColumnName) < '02:00:00.000000'
Assuming that booking_time
is in MySQL standard format.假设
booking_time
是MySQL 标准格式。
Try this and the below query will use index if you have one in booking_time
column试试这个,如果你在
booking_time
列中有一个,下面的查询将使用索引
SELECT *
FROM booking_table
WHERE booking_time BETWEEN CURRENT_TIMESTAMP() - INTERVAL 2 HOUR AND CURRENT_TIMESTAMP()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.