Answer the question
In order to leave comments, you need to log in
Is the calculation of the day correct?
Hey!
On the server, you need to make a selection from the database depending on the time.
The condition is as follows: the sampling occurs from 4:00 of the current day to 3:59 of the next day, the
sampling occurs every 15 minutes.
That is, if the script is launched on 23.07 at 12:15, then the selection should be from 23.07 4:00 to the current moment, that is, just more than 23.07 4:00
and if the script is launched on 24.07 at 2:30, then the selection is the same from 23.07 4:00 to date.
but as soon as it crosses the 4:00 boundary, the current day is already selected as the start date.
sort of wrote a selection of the day to insert into the script:
import datetime
a = datetime.datetime.today()
b = a.day
if a.hour < 4:
b = (a - datetime.timedelta(1)).day
print(b)
(a - datetime.timedelta(1)).day
legal?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question