Good morning friends, I have the following doubt and it is how I can bring the data of a table as long as 48 are missing with the date that I pass to it, and with the field of the table. To put them more in context, it consists of the following: we have a table called events, and in this table there is a date field, which tells us when the event starts, what I want to do is send it the date of the server, for when 48 are missing hours notify you via email.
I used the following code but it didn't work as I expected: For this example we have that the event starts on February 10, what we want is that when there are 48 hours left according to the date that I give it, it brings me that result (it should be clarified that if there are missing more or less than 48 should not bring me that record)
SELECT ee.*
FROM events_events ee
where ee.event_date_from > '2022-05-08' + interval 48 hour
I will gladly receive any comment and I hope you can help me.
I have a test that can help you with this.
I have a table called "dates" with this information:
Assume your event date is "datetimeInit".
So we do the following:
Where:
So we get the following:
With this you can already have control of the hours you want and that you want to validate. For example if secondsDiff is less than or equal to 48:00:00 then you should already send the mail.
Note: The server time is simulated with the computer system time, and the event dates as future days.
I hope it will be very helpful to you.