Month to Date

  • Thread starter Thread starter ChuckW
  • Start date Start date
C

ChuckW

Hi,

I want to run a query with a date field that will get
everything months to date. I know there is some specific
code that will do this. Also, is there a place that list
what the code would be for this week, this month, last
month, this year etc.?

Thanks,

Chuck
 
The first of this month is:
Date() - Day(Date()) + 1
The last of this month is:
DateAdd("m", 1, Date() - Day(Date()) + 1) - 1

The first day of this week is:
Date() - Weekday(Date()) + 1
Should you need to start counting from Monday use:
Date() - Weekday(Date(), 2) + 1
or use 3 for Tuesday, etc.
The last day of this week is:
Date() - Weekday(Date()) + 7

The first of last month is:
DateAdd("m", -1, Date() - Day(Date()) + 1)
The last of last month is:
Date() - Day(Date())

The first of this year is:
DateSerial(Year(Date()), 1, 1)
and the last is:
DateSerial(Year(Date()), 12, 31)
 
Back
Top