Calculate days in a month

D

dimpie

User inputs - Month and year, I need to figure out the last day of the month
for that year (keeping Leap year in mind).

Is there a function in VBA that i can use to get the last day of the
specified mnth and year. If there is not, can you help me figure this out.

Thanks a lot for your help!
 
D

Dirk Goldgar

dimpie said:
User inputs - Month and year, I need to figure out the last day of the
month
for that year (keeping Leap year in mind).

Is there a function in VBA that i can use to get the last day of the
specified mnth and year. If there is not, can you help me figure this out.

Thanks a lot for your help!


The date of the last day of [YearNo], [MonthNo] can be calculated as:

DateSerial([YearNo], [MonthNo] + 1, 0)

The day number, then, is:

Day(DateSerial([YearNo], [MonthNo] + 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