Script - get calendar week number (but start with Monday not Sunday)

i need some hint about
I need to format date to string like: “dd. MM. YYYY/w”
That w is calendar week. But when I use this function I get Calendar weeks starting by Sunday (so if the date is hits Sunday, KW number is wrong for me).

a) Do you know any elegant way how get KW starting by Monday (some settings or elegant code).
b) There is option to use ifs and add +1 if this is Sunday (but this is plan B for me).

Thank you

Since uses the java SimpleDateFormat and SimpleDateFormat uses the Locale to determine which day is the start of the week, I assume that this is based on the project’s locale?

Perhaps @PGriffith or @cmallonee can speak more to this?

Java’s Calendar class allows you to set the first day of the week (docs). If you’re comfortable importing classes from Java this would be the easiest way.


Look at the strftime method from date time.

import datetime
today =
year, week, day = today.isocalendar()

# adjust for the week starting at 0
weekStartSun = int(today.strftime("%U")) + 1
weekStartMon = int(today.strftime("%W")) + 1

print year, week, weekStartSun, weekStartMon


Thank you,
i reused your example.