View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Function for week number

On Tue, 13 Jan 2009 13:09:41 -0500, "Rick Rothstein"
wrote:

Does your function actually do what you intend it to? I ask because the
calculation you do immediately after assigning a value to your
SisteUkeDagIÅret variable would seem to indicate you do not want to report a
weeknumber of 53


Actually, that's a workaround to try to deal with one of the errors in DatePart
(or Format). This particular error is documented by Microsoft
http://support.microsoft.com/kb/200299

But there's another error, which was pointed out to me by Hans Terkelsen a few
years ago, which causes several other incorrect results.

He liked this function:

==========================
Function WkIso(d) '..1/1/100-31/12/9999..
WkIso = ((((d + 692501) \ 7 Mod 20871) * 28 + 4383) _
Mod 146096 Mod 1461) \ 28 + 1
End Function
==========================

I supplied another function by Daniel Maher in my response to the OP.
--ron