WEEKNUM Returning 53 Instead of 1

bonzo

Board Regular
Joined
Oct 23, 2002
Messages
79
For Sun, 12/29/02, Mon, 12/30/02, and Tue, 12/31/02, the WEEKNUM() worksheet function is returning 53 instead of 1. The dates for the rest of this week are all returning a 1.

To compensate for this, I have the following:

=IF(WEEKNUM(A1)=53,1,WEEKNUM(A1))

but I have to go through and change all of the cells that have WEEKNUM() to have the above conditional.

Is there already a recommended way to do this? Or, is there a way, perhaps, to override the WEEKNUM() worksheet function with my own version of WEEKNUM()?

Thanks...
 
From the help files on Weeknum

Returns a number that indicates where the week falls numerically within a year.

So it should return 53
 
Upvote 0
Hi Bonzo,

Which weeknumber is correct?
It´s depend on where You live in the world.

For US-people the correct weeknumber is 53, which also the XL-built-in weeknumber-function also calculate with.

For me in Sweden the correct weeknumber is 1.
For You it seems also that the correct weeknumber should be 1.

Yes, we can start a long thread about ISO-weeks and so on but I will not do that.

To compensate it and get the correct week-number use following function:

<pre>
Option Explicit

Function WEEKNR(Datum As Date) As Integer
Dim lnDatum As Long

lnDatum = DateSerial(Year(Datum - Weekday(Datum - 1) + 4), 1, 3)

WEEKNR = Int((Datum - lnDatum + Weekday(lnDatum) + 5) / 7)

End Function
</pre>

I guess that we can´t make a shorter function then above :wink:

Kind regards,
Dennis
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top