Calculate a date knowing the week number and year

G

Guest

Does anyone know how to calculate a date based off of a year and the week #
(i.e. year 2006 and week 31 would equal 7/31/06 which is the first day of
week 31) ?

Thanks,

Sarah
 
G

Guest

You have to have at least a year that you want to use. It couldn't be done
with a week number alone.
This will return the Monday of the week

lngWeeks = 31
lngYear = 2006
dtmBegin = DateValue(lngYear, 1, 1)
dtmBegin = DateAdd("ww", lngWeeks - 1 , dtmBegin)
dtmFinal = DateAdd("d", vbMonday - DatePart("w", dtmBegin), dtmBegin)
 
G

Guest

Thanks the first one worked great. Exactly what I was looking for.

Thanks again and have a great day!

Sarah
 
G

Guest

Datevalue only takes one arguement.

Klatuu said:
You have to have at least a year that you want to use. It couldn't be done
with a week number alone.
This will return the Monday of the week

lngWeeks = 31
lngYear = 2006
dtmBegin = DateValue(lngYear, 1, 1)
dtmBegin = DateAdd("ww", lngWeeks - 1 , dtmBegin)
dtmFinal = DateAdd("d", vbMonday - DatePart("w", dtmBegin), dtmBegin)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top