1

I am trying to convert the date into week number of year.

In my case, I cannot include the day of one year into another year.

The isocalendar() works fine to find week number, however, it assumes some rules: if the first week in January has less than 4 days, it is counted as the last week of the year before.

So, this function returns:

date(2016, 1, 1).isocalendar()[1] 53 

Is there some way, using this function, to change this, to return week 0 instead of week 53 (from previous year) ?

1

1 Answer 1

2

how about this?

import datetime datetime.date(2016, 1, 1).strftime("%U") 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.