Python date.weekday() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
date method

Definition

weekday() returns the day of the week as an int: 0 for Monday, 1 for Tuesday, up to 6 for Sunday.

The numbering matches the calendar module constants (calendar.MONDAY is 0), and it is one less than isoweekday(). Because it is a small int, it works well with modulo arithmetic for "next Monday" style calculations.

date.weekday() is an instance method of datetime.date: call it on an existing object with dot notation, such as day.weekday(...). Import the class first, for example from datetime import date. The datetime class has a method with the same name.

Syntax

Call it with no arguments.

python
number = day.weekday()
CallWhat it does
date(2024, 1, 1).weekday()Returns 0: Monday.
datetime(2024, 3, 15, 23, 59).weekday()Returns 4: Friday; the time is ignored.
date(2024, 3, 17).weekday()Returns 6: Sunday.

Weekend test: day.weekday() >= 5.

Method signatures
python
date.weekday()
datetime.weekday()
# returns: int, 0 (Monday) .. 6 (Sunday)

Parameters

weekday() takes no parameters.

Return Value

Return ValueDescription
int0 for Monday through 6 for Sunday.

Python Examples

Example 1 — Get Weekday Numbers for Fixed Dates

A Monday, a Friday late at night, and a Sunday.

python
from datetime import date, datetime

print(date(2024, 1, 1).weekday())
print(datetime(2024, 3, 15, 23, 59).weekday())
print(date(2024, 3, 17).weekday())

How It Works

  1. Monday first. 1 January 2024 is a Monday, so the result is 0.
  2. Time ignored. 23:59 on Friday is still Friday, number 4.
  3. Sunday last. Sunday is the highest number, 6.

Example 2 — Find the Next Monday, Friday, or Saturday

Use modulo 7 to count the days until the next target weekday, always moving forward at least one day.

python
from datetime import date, timedelta


def next_weekday(start, target):
    days_ahead = (target - start.weekday()) % 7 or 7
    return start + timedelta(days=days_ahead)


friday = date(2024, 3, 15)
print(next_weekday(friday, 0))
print(next_weekday(friday, 4))
print(next_weekday(friday, 5))

How It Works

  1. Distance with modulo. (0 - 4) % 7 is 3, so the next Monday is three days after Friday.
  2. Never today. When the target is the same weekday, the modulo gives 0 and or 7 jumps a full week.
  3. Tomorrow. Saturday (5) is one day after Friday (4).

Example 3 — Find the Last Friday of Each Month

Step back from the last day of the month to the nearest Friday.

python
from datetime import date, timedelta


def last_friday(year, month):
    first_next = date(year + month // 12, month % 12 + 1, 1)
    last_day = first_next - timedelta(days=1)
    return last_day - timedelta(days=(last_day.weekday() - 4) % 7)


for month in (1, 2, 12):
    print(last_friday(2024, month))

How It Works

  1. Last day of the month. The first day of the next month minus one day handles 28, 29, 30, and 31-day months.
  2. December wraps. month // 12 and month % 12 + 1 turn December 2024 into 1 January 2025.
  3. Step back to Friday. (weekday - 4) % 7 is how many days to go back; for Wednesday 31 January it is 5, giving 26 January.

Frequently Asked Questions

6. Monday is 0.
Use calendar.day_name[day.weekday()] or day.strftime("%A"); both follow the locale.
day.weekday() < 5.
getDay() starts with Sunday as 0. Python weekday() starts with Monday as 0.
Both are fine. weekday() suits list indexes and modulo math; isoweekday() matches ISO 8601 and human numbering.

Back to the method index

See all 29 datetime method guides grouped by what they do.

Method Index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful