I created a query to pull the current weeks Monday but can't figure out how to convert that to a string and create a variable that prints it in this format ('%Y/%m/%d')
import datetime
today = datetime.date.today()
today + datetime.timedelta(days=-today.weekday())
Solved! Go to Solution.
for python 3 don't forget print is different
print(mon.strftime("%Y/%m/%d"))
Try:
mon = today + datetime.timedelta(days=-today.weekday())
print mon.strftime("%Y/%m/%d")
for python 3 don't forget print is different
print(mon.strftime("%Y/%m/%d"))
Don't forget that .weekday() for Sunday = 6, so the Monday for Sunday 2018/09/09 is 2018/09/03 and not the following day (the 10th).