|
Question : Week Starting Monday
|
|
I found the following function on EE to get the week starting with Monday.
DatePart("ww",[ProdDate]-1)
When I run it for May, it works fine. I projected it on dates for many years ahead. I found that it is producing a 53rd week for the date 1/1/2007. I don't understand since 1/1/07 is a Monday. Can anyone clarify for me?
ProdDate ProdWeek 12/30/2006 52 12/31/2006 52 1/1/2007 53 1/2/2007 1 1/3/2007 1 1/4/2007 1
This is important as I think I will get bad data when I run for the beginning of the year. Please help.
Scotto13
|
|
Answer : Week Starting Monday
|
|
Hello Scotto13
I think I see the problem. You subtract 1 to get weeks starting on Monday (instead of the default US weeks strating on Sundays for some strange and perhaps fascinating historical reason). To get the week numbers you want, you can use these additional parameters for DatePart:
FirstDayOfWeek: vbSunday = 1 (default) to vbSaturday = 7 FirstWeekOfYear: vbFirstJan1 = 1 (default) vbFirstFourDays = 2 vbFirstFullWeek = 3 vbUseSystem = 4
Thus you could use instead:
DatePart('ww', ProdDate ,2, 1)
Note: Sadly, EE does contain some shabby "solutions" like the one you discovered. You should be aware that there is no quality control other than questioners accepting answers...
Cheers! (°v°)
|
|
|
|