find number of days in a month

R

Rick Brandt

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))
 
B

Brian Camire

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))
 
B

Bruce M. Thompson

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))
 

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