I want to find out the following: given a date (datetime object), what is the corresponding day of the week?
datetime
For instance, Sunday is the first day, Mond
A simple, straightforward and still not mentioned option:
import datetime ... givenDateObj = datetime.date(2017, 10, 20) weekday = givenDateObj.isocalendar()[2] # 5 weeknumber = givenDateObj.isocalendar()[1] # 42