I'm needing to write an expression that calculates the week number for any date for the month it's in, given that all weeks begin on Monday and all months begin on the first Monday of the month.
In other words, the 5th week of October, 2011 would begin on 10/31/11 and end on 11/06/11. The first week of November would then begin on 11/7/11, etc.
The resulting query would display something like the following:
10/27/11 OCTOBER 4
10/28/11 OCTOBER 4
10/31/11 OCTOBER 5
11/02/11 OCTOBER 5
11/08/11 NOVEMBER 1
I have been able to get the month to display correctly using the following expression:
IIf(Weekday([py end date],2)=1,Format([py end date],"mmmm"),Format([py end date]+1-Weekday([py end date],2),"mmmm"))
I can get the week number in Excel, but can't seem to figure out how to do the same in Access. Any help would be greatly appreciated!
In other words, the 5th week of October, 2011 would begin on 10/31/11 and end on 11/06/11. The first week of November would then begin on 11/7/11, etc.
The resulting query would display something like the following:
10/27/11 OCTOBER 4
10/28/11 OCTOBER 4
10/31/11 OCTOBER 5
11/02/11 OCTOBER 5
11/08/11 NOVEMBER 1
I have been able to get the month to display correctly using the following expression:
IIf(Weekday([py end date],2)=1,Format([py end date],"mmmm"),Format([py end date]+1-Weekday([py end date],2),"mmmm"))
I can get the week number in Excel, but can't seem to figure out how to do the same in Access. Any help would be greatly appreciated!