Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

is there any standard way to associate a ISO week number with a specific month?

Let's say we have week 35 this year (from 08/29/2011 to 09/04/2011), does this week belong to August or September?

I'm looking for a standard or the most common way of doing it.

Why I need this is for some statistics. Something like: sum earnings of every first week in month for the last 5 months.

share|improve this question
1  
Define belong? Does a week spanning both August and September belong to both, the month it starts, the month it spends most time in? –  Phoshi Jun 6 '11 at 11:58
    
Well, that's exactly what I'm asking. I don't know where does it belong, but I would need one month. If you take a look at the ISO week in a year standard, you see it might happen that 2nd of January (like in year 2010) actually belongs to the last week (number 53) in year 2009. And so you can say week 53 belongs to year 2009. Now I would need some similar standard or "the common way" for saying week 35 is in August (or in whatever month). For example: standard XX says: if Thursday of week 35 is in August than week 35 "is" in August. –  Armen Ablak Jun 6 '11 at 18:01
    
By your own argument, a week "belongs" to the year that the week begins in. It would make sense that a week would also "belong" to the month that it begins in. –  William Jackson Jun 6 '11 at 19:07

1 Answer 1

up vote 0 down vote accepted

The first iso_week contains the first thursday of the year, so it is a consistent practice to define the month of the iso week as that which contains the thursday (day 4) of the week.

iso_date = (iso_year, iso_week, 4)

convert to common date and extract the month.

That way you make sure that the first iso_week of a year belongs to january, and the last iso_week of a year belongs to december.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.