Period based on week number

sponge

Registered User.
Local time
Today, 02:04
Joined
Jul 12, 2005
Messages
44
Hi,

I've got a combo box that uses
DatePart("ww",[Date],2) AS WkNum
to obtain the week number.

How would I obtain the start date and the end date from just the week number?

Is it also possible to change WkNum to the week number of the selected month?
E.g. if December is selected, instead of week 53, show week 5.

Any help would be much appreciated.
 
Last edited:
I dont think you could based solely on the weeknumber... I think you would need the year also. Here's how you can do it with a full date.

Sunday: [Date]-(Weekday([Date])-1)

Saturday: [Date]+(7-Weekday([Date]))

You can fiddle with the equation to get Monday/Friday
 
If you have the original date why not just use that:)
Still this should do it but I have not tested it much!
It assumes that the first day of week is Moday and uses European standard for first week of year

Code:
Function funWeekDate(intWeek, intyear) As Date
Dim intDay As Integer
intDay = DatePart("w", (DateSerial(intyear, 1, 1)), vbMonday)
If intDay <> 1 Then intDay = 9 - intDay
funWeekDate = DateSerial(intyear, 1, intDay + ((intWeek - 1) * 7))
End Function

Peter
 

Users who are viewing this thread

Back
Top Bottom