I want the number of days from Monday. Like on Thursday it should return 4. Below is the code, its not giving relevant result
import datetime
dt = datetime.datetime.now()
dt.weekday()
I want the number of days from Monday. Like on Thursday it should return 4. Below is the code, its not giving relevant result
import datetime
dt = datetime.datetime.now()
dt.weekday()
Weekday returns day number in format Monday -> 0, Tuesday -> 1 etc. etc., if you want it to start from one, just add 1 to the result.
According to the documentation isoweekday should do the trick
import datetime
dt = datetime.datetime.now()
dt.isoweekday()
returns 4 on Thursday
You can calculate it normally and add one to the answer:
import datetime
dt = datetime.datetime.now()
print(dt.weekday()+1)
or use the standard (official) method:
import datetime
dt = datetime.datetime.now()
dt.isoweekday()