• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Count nth week of month starting from Sunday...how to do this?

PP3321

Active Member
My requirement is to display week number, based on Sunday.
So, 1st week starts from the 1st Sunday of the month.

<My Current Solution>
I used Countif function.

<Problem of above solution>
Problem is that when the month changes, I cannot reset to 0 and start again.

I would be grateful if you could give me clues how I can achieve this.
Macro, Formula, Date Functions...any tool is OK...

*I am using Excel 2010

Thanking you in advance...

screenshot.png
 
You can also choose to use following construct which is not dependent on previous cell's result. It will refer to the date in column A.
=INT((A2-(EOMONTH(A2,-1)+9-WEEKDAY(EOMONTH(A2,-1)+1)))/7)+1
The above formula result will be failed if 1st of the month is Sunday.

Example in the month of Jan 2017, Oct 2017, April 2018….etc.

01/01/2017 (Sun)… return 0 (should be 1)
02/01/2017 (Mon)… return 0 (should be 1)
………………..
………………..
01/10/2017 (Sun)… return 0 (should be 1)
02/10/2017 (Mon)… return 0 (should be 1)
………………..
………………..

Regards
Bosco
 
Bosco is right! I had not tested above condition. Here's revised approach which takes care of Bosco's point.
=CEILING((DAY(A2)+WEEKDAY(EOMONTH(A2,-1))-7)/7,1)
It does not rely on previous cell's result like previous formula.
 
Bosco is right! I had not tested above condition. Here's revised approach which takes care of Bosco's point.
=CEILING((DAY(A2)+WEEKDAY(EOMONTH(A2,-1))-7)/7,1)
It does not rely on previous cell's result like previous formula.
Thanks shrivallabha,

1] Nice formula, improved and made shorter.

2] 1st of the month is Sunday problem is solved.

3] Some of the months starting days should give 0, however the formula return #NUM!,

e.g. 01/06/2016, 02/06/2016, 02/06/2016, 01/07/2016, 01/08/2016……etc.

Regards
Bosco
 
Thanks shrivallabha,

1] Nice formula, improved and made shorter.

2] 1st of the month is Sunday problem is solved.

3] Some of the months starting days should give 0, however the formula return #NUM!,

e.g. 01/06/2016, 02/06/2016, 02/06/2016, 01/07/2016, 01/08/2016……etc.

Regards
Bosco
Bosco,

Thanks for testing. I do not get this error mentioned in 3rd point. It gives me 0.

I am attaching my file for reference. Could you check if it also shows erroneous results at your end?
 

Attachments

  • pp3321.xlsx
    25.6 KB · Views: 6
Bosco,

Thanks for testing. I do not get this error mentioned in 3rd point. It gives me 0.

I am attaching my file for reference. Could you check if it also shows erroneous results at your end?
Thanks shrivallabha,

I find the problem, my testing file is a Excel 2003 xls file, your attached file is a xlsx file.

Regards
Bosco
 
Back
Top