find number of days in a month

  • Thread starter Thread starter Alex Soren
  • Start date Start date
Alex Soren said:
How to find number of days in a month inside a query

Do you need to evaluate a month by number, or by starting with a date
value?

For the former (1 = January, 12 = December, etc.)...
DaysInMonth: Day(DateSerial(Year(Date()), [YourField]+1, 0))

For the latter (using a date field)...
DaysInMonth: Day(DateSerial(Year(Date()), Month([YourField])+1, 0))
 
Assuming you have fields named "Month" (with values from 1 to 12) and "Year"
(with the four-digit year), you might use an expression something like this:

DateDiff("d", DateSerial([Year], [Month], 1), DateSerial([Year], [Month] +
1, 1))
 
How to find number of days in a month inside a query

I assume that you are using a field containing a date so that your value will
account for leap year:

Format(DateSerial(Year([MyDateField]),Month([MyDateField])+1,0),"d")

.... or ...

Datepart("d",DateSerial(Year([MyDateField]),Month([MyDateField])+1,0))
 
Back
Top