I want a query that dynamically fetches data greater than the current time today and less than 24 hours today. If necessary, it should also include data for the next day based on the specified hours value. For example, if I provide hours = 2, the query should fetch data for the next 2 hours from the current time today. However, if I provide hours = 19, the query should return “no rows” if the data does not exist.
Currently, my query retrieves data for today within the next 24 hours, which works fine. However, if I provide a value like hours = 17 or dynamically between 24 hours, it does not include data for the next day if the time exceeds midnight. I need help resolving this issue.
now this query get today data less than or greater than current time..
SELECT *
FROM jobDetails jd
WHERE TIME(time) > TIME(CONVERT_TZ(NOW(), ‘+00:00’, ‘+05:00’))
AND TIME(time) <= TIME(DATE_ADD(CONVERT_TZ(NOW(), ‘+00:00’, ‘+05:00’), INTERVAL ? HOUR));
get data next day 24 hours include another condition.