如果添加的日期和当前日期之间的持续时间不大于或等于2小时,则获取数据

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.

I want to generate a query that returns all the bookings whose booking time is less than 2 hours. How can I achieve this?

This is my database structure. Image

You can extract the hour part of your date. Refer to this link

Then using this query to get those less than 2 hours.

SELECT * FROM table1 WHERE tdate - 120 < EXTRACT(MINUTE FROM now()) 
SELECT * FROM `TableName` where TIMEDIFF(NOW(),Your_date_ColumnName) < '02:00:00.000000'

Assuming that booking_time is in MySQL standard format.

Try this and the below query will use index if you have one in booking_time column

SELECT * 
FROM booking_table 
WHERE booking_time BETWEEN CURRENT_TIMESTAMP() - INTERVAL 2 HOUR AND CURRENT_TIMESTAMP()