Greetings to all, I have the following:
In my database I keep records every day, additionally the system also saves the date and time that are two variables that are called: (retirement_date, time).
I have the following query:
SELECT id_reit,cliente,codigo_reit,descri_reit,cantidad_reit,fecha_retiro,
quien_retiro,ubicacion,estante,nivel,hora,
SUM(cantidad_reit) AS sumacantidadtw
FROM retiro_items
WHERE cliente='$acliente'
AND categoria='Operacion'
AND fecha_retiro BETWEEN '2021-06-10' AND '2021-06-11'
AND hora BETWEEN '06:00' AND '06:00'
The problem is that I also want it to bring me the registered data not only on the current date for example: 06/10/2021 but also to bring me the registered data from 06/10/2021 at 6:00 am until 06:00 am the other day 06/11/2021. would be the records of the last 24 hours.
How could I do this? By date it works perfectly for me but I don't know how to do it also by the hour variable.
Any help could be of great use to me.
Thank you very much.
I think I have found a solution.
Seeing that you have separate DATE and TIME, I recommend joining them as follows:
Thus, we have created a new result column, such as timestamp. Now, we can use it to filter between the assigned dates and times.
Try this one, it brings the log 24 hours back from the current date and time