I am trying to filter my query data to only return items where "Meeting Start"
is greater than CURRENT_TIMESTAMP
but not later than 12 hours from the CURRENT_TIMESTAMP.
Can I add 12 hours to the CURRENT_TIMESTAMP inline below in my query?
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 ";
DATE_ADD() function in MySQL is used to add a specified time or date interval to a specified date and then return the date. Syntax: DATE_ADD(date, INTERVAL value addunit) Parameter: This function accepts two parameters which are illustrated below: date – Specified date to be modified.
The DATE_SUB() function subtracts a time/date interval from a date and then returns the date.
NOW() + INTERVAL 12 HOUR
should do the trick. +12
is ambiguous. 12 seconds? minutes? days? years?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With