Getting the Day of the Week in Python
To get the current day of the week, use the weekday
property. It returns numbers from 0
to 6
, where the week starts on Monday and this day has the number 0
. Tuesday is day number 1
, Wednesday is number 2
, and so on.
Let's output the day of the week on which the date '2025-12-31'
falls:
res = datetime.date(2025, 12, 31)
print(res.weekday()) # 2
Since numbering the days of the week starting with 0
can sometimes be inconvenient, you can use the special property isoweekday
. It will output the day number when counting Monday from 1
:
print(res.weekday()) # 2
print(res.isoweekday()) # 3
Display the current day of the week number on the screen.
Determine whether the current day of the week is a weekend or a working day.
Date date '2026-11-2'
. Output its day of the week for two cases - when counting Monday from 0
and when counting from 1
.