Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating the week number in Excel

17 views
Skip to first unread message

Nimmi Srivastav

unread,
Apr 20, 2008, 9:07:32 AM4/20/08
to
I am using the following formula to compute the week number based on
the ISO standard ISO8601:2000


=INT((B4-DATE(YEAR(B4-WEEKDAY(B4-1)+4),1,3)+WEEKDAY(DATE(YEAR(B4-
WEEKDAY(B4-1)+4),1,3))+5)

(http://msdn2.microsoft.com/en-us/library/bb277364.aspx)


As per this formula, 1/1/2009 should be week 1. However, as per my
Outlook calendar 1/1/2009 through 1/3/2009 show up as week 53. Can
someone kindly explain the discrepancy?

Thanks,
NS

Ron de Bruin

unread,
Apr 20, 2008, 9:22:32 AM4/20/08
to
Hi Nimmi

Outlook is not using the ISO Standard

See
http://www.rondebruin.nl/weeknumber.htm

If you download the calandar file you can see the differents

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Nimmi Srivastav" <nimmi_s...@yahoo.com> wrote in message
news:487287d0-2275-4d78...@8g2000hse.googlegroups.com...

Shane Devenshire

unread,
Apr 20, 2008, 11:53:41 AM4/20/08
to
Hi Nimmi,

Assuming you are entering your dates as m/d/y then you could use the
following formula:

=INT((B2+SUM({1,-1}*MOD("1/2/"&YEAR(B2-MOD(B2-2,7)+3),{7,1E+99}))+5)/7)

or you could use a VBA function:

Public Function ISOWeekNum(mydate As Date) As Byte
D = mydate - 2
T = CDate("1/2/" & year(D - D Mod 7 + 5))
ISOWeekNum = (D - T + T Mod 7 + 4) / 7
End Function

I dimmed the variables at the Module level, so they don't show here. In the
spreadsheet the function reads =ISOWeekNum(A1) where A1 contains 1/1/2009.

Cheers,
Shane Devenshire
Microsoft Excel MVP

"Nimmi Srivastav" <nimmi_s...@yahoo.com> wrote in message
news:487287d0-2275-4d78...@8g2000hse.googlegroups.com...

0 new messages