Calc number of days in current month

G

Guest

How can I calculate the number of days in the current month.

i.e. If the current month is May how do I retrun 31?

Bruce
 
N

Nikos Yannacopoulos

Bruce,

This expression does it:

DateAdd("m",1,Date()-Day(Date())+1)-(Date()-Day(Date())+1)

HTH,
Nikos
 
T

Tom Lake

Nikos Yannacopoulos said:
Bruce,

This expression does it:

DateAdd("m",1,Date()-Day(Date())+1)-(Date()-Day(Date())+1)

HTH,
Nikos

Or alternately:

DateSerial (Year(Date()),(Month(Date())+1),0)

Tom Lake
 
N

Nikos Yannacopoulos

Tom said:
Or alternately:

DateSerial (Year(Date()),(Month(Date())+1),0)

Tom,

This will return the date of the last day in the current month; it
requires the use of Day() on the result to return the count of days in
the month as per the OP.

Regards,
Nikos
 
T

Tom Lake

Tom said:
Tom,

This will return the date of the last day in the current month; it
requires the use of Day() on the result to return the count of days in the
month as per the OP.

Yup, so it does:

Day(DateSerial (Year(Date()),(Month(Date())+1),0))

Tom Lake
 

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