Set Date to the upcoming monday

J

john

I need to set a date to the next monday, the DateSerial sets it to the first
monday in the month and then I use a loop to advance it where I need it.

Is there a better way to do it with just the dateserial or some othe method?

d = DateSerial(Year(Date), Month(Date), Day(vbMonday))
Do Until i > Date
d = DateAdd("ww", 1, d)
Loop

Thanks John
 
D

Douglas J. Steele

Day(vbMonday) is a pretty meaningless expression. vbMonday is a constant
that's equal to 2. The Day function expects a date, so because of how Access
stores dates, it's going to see 2 as being equal to 1 Jan, 1900, hence it'll
return the value 1.

Take a look at my June, 2005 "Access Answers" column in Pinnacle
Publication's "Smart Access": I demonstrate a function that will calculate a
specific weekday in a month. You can download the column (and sample
database) for free at http://www.accessmvp.com/djsteele/SmartAccess.html
 

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