Python Practice › Datetime Programs › Program 17
Day of the year and week number
Write a Python program to get the day of the year and ISO week number of a date.
Output
306 45
Approach
timetuple().tm_ydayandisocalendar().
Solution
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.