Thread: Weeknum
View Single Post
  #3   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Tue, 28 Jun 2005 02:24:03 -0700, MickeW
wrote:

I work in a Swedish environment, and would like to use the function Weeknum,
the thing is, that Sweden uses a different way to number our weeks, for
example, the date 2005-01-01, is weeknumber 53, but if I use the function
Weeknum, it computes to weeknum 1. Is there anyone who has any suggestions of
how to tackle that problem?

MickeW


You can use this UDF:

=======================
Function ISOWeeknum(DT As Date) As Integer
ISOWeeknum = DatePart("ww", DT, vbMonday, vbFirstFourDays)
If ISOWeeknum 52 Then
If DatePart("ww", DT + 7, vbMonday, vbFirstFourDays) = 2 Then
ISOWeeknum = 1
End If
End If
End Function
=======================

To use this, <alt-F11 opens the VB Editor. Ensure your project is highlighted
in the project explorer window, then Insert/Module and paste the above code
into the window that opens.

To use this UDF, enter =ISOWeeknum(A1) into some cell. Substitute for A1 your
cell containing the date to be converted.


--ron