Set Date

  • Thread starter Thread starter gr
  • Start date Start 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!
 
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)
 
Back
Top