Basically I am looking for some kind of method to calculate the business the day before yesterday since I have to run a t-2 query without any manual interference in the datetime variable:
In a nutshell:
27.05.21 -> 25.05.21
Today's date is a dynamic variable changing every day of course and you should consider weekends e.g. 31.05.21 -> 27.05.21
I worked myself off on the "get the last business day method" to modify it...
today = datetime.today()
offset = max(1, (today. weekday() + 6) % 7 - 3)
timedelta = datetime. timedelta(offset)
most_recent = today - timedelta
print(most_recent)
...but I failed miserably and is not worth to mention here.
Any help would be highly appreciated!
Thanks a lot!
Ciao R