# week numbers in month. How to work it out?

ok, I am being stupid!

I am doing a project plan and for each month I have the weeks 1-4.

My question is, how to know which week number a particular date belongs to?

I've played with outlook but it only displays week numbers for the whole year, which is no good.

Anyone know an online resource where I can just look back in the past and into future for week numbers for a month?

-

Firstly, you should note that there are an average of 4 1/3 weeks per month. So if you use only 1-4 weeks, you will not be able to represent all the dates.

That aside, if you divide by 7 and round up, you get a week number between 1 and 5.

`WeekNumber = Ceiling(DayofMonth / 7)`

-
does day 7 belong to week 1 or week 2? i think the correct formula uses ceiling() (or upper(), same thing), not floor()+1. as another example, note Feb 28th is in week 5 according to this formula. –  quack quixote Mar 3 '10 at 11:38
Depends if it's been a long day in Australia or not :). You are indeed correct. Updated accordingly. –  Dan McGrath Mar 3 '10 at 11:45

Just look at the day of the month. Week number is `upper(day_number / 7),` i.e. you need to divide day number by 7 and round it to the next integer. Remember that there can be a 5th week too. For example March 31, belongs to week number 5.

This is rarely required, so I wasn't able to find any online resource, but have create such a plan on my own: http://spreadsheets.google.com/ccc?key=0AtS8km6a08YmdFFmVGdXdk8xR0tITk5mZ2ttaXI1bHc&hl=en

-

Is this what you are looking for,
If a month starts with last day of a week, then the second day of the month belongs to second week of the month....
Then try this,

`temp = quotient(DayOfMonth/7)if remainder(DayOfMonth/7) > DayOfWeek:. . . WeekNumber = temp+1else:. . . WeekNumber = temp`

This is just the logic....

-

Technically every calendar program supports a view called 'Month'. F.e. Sunbird will show the calendar in that view as five to six rows, with each representing a week:

However, I don't know what your project considers a week within a month.

-