Set Date

G

gr

Hi, I'm trying to find out how to Set two textboxes values
to the First day and last day of the week (of the current
week)
Example, if Today is 01/03/2004 (Monday)

txtBegin: 01/03/2004 (Monday)
txtEnd: 05/03/2004 (Friday)

But if Today was 10/03/2004 (Wednesday)

txtBegin: 08/03/2004 (Monday)
txtEnd: 12/03/2004

It's easy to pick the year and month but how to pick the
day corresponding to the Monday's and Friday's current
week?

DateSerial(Year(Date), Month(Date), ?????)

Thx!
 
M

Marshall Barton

gr said:
Hi, I'm trying to find out how to Set two textboxes values
to the First day and last day of the week (of the current
week)
Example, if Today is 01/03/2004 (Monday)

txtBegin: 01/03/2004 (Monday)
txtEnd: 05/03/2004 (Friday)

But if Today was 10/03/2004 (Wednesday)

txtBegin: 08/03/2004 (Monday)
txtEnd: 12/03/2004

It's easy to pick the year and month but how to pick the
day corresponding to the Monday's and Friday's current
week?

DateSerial(Year(Date), Month(Date), ?????)


Don't know what you want to do about weekends, but try this:

DateSerial(Year(Date()), Month(Date()), Day(Date()) + 1 -
DatePart("w", Date(), 2))

Or:
DateAdd("d", 1 - DatePart("w", Date(), 2), Date())

Or, with a little cheating:
Date() + 1 - DatePart("w", Date(), 2)
 

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