[Tutor] how to get the weeks of a month

john fabiani johnf at jfcomputer.com
Mon Mar 4 13:54:03 EST 2019


Hi everyone,

I'm not exactly a newbie but I can't seem to solve this problem.

I need to print out the weeks of the month - given any month and any year.

For example this month would have:

3/1/2019 - 3/3/2019   # notice that this a short week
3/4/2019 - 3/10/2019
3/11/2019 - 3/17/2019
3/18/2019 - 3/24/2019
3/25/2019 - 3/31/2019  # also this can be a short week as in April 2019 
last week would be 4/29/2019 - 4/30-2019

I have tried using isocalendar, dateutil, and just plain datetime.

I get close but no real solution. Google wasn't much help either.  So I 
thought I'd ask here - you have been helpful in the past.  And no at my 
age I am not attending school - so this not my homework.

Johnf



More information about the Tutor mailing list