Day of the year and week number

EasyDatetime Programs · 17 of 20

Write a Python program to get the day of the year and ISO week number of a date.

Advertisement
Output
306 45

Approach

  1. timetuple().tm_yday and isocalendar().

Solution

Python
from datetime import date d = date(2026, 11, 2)print(d.timetuple().tm_yday, d.isocalendar().week)
Output
306 45

Learn the concept

New to this topic? Read the lesson, then come back.

More datetime programs

← All 20 Datetime Programs

Leave a Comment