Nr of Days in a Month

  • Thread starter Thread starter Isabelle
  • Start date Start date
I

Isabelle

Does anyone has a function or routine that
can find out or calculate the exact nr of days in a month?

For example if month = 2 (feb)
that the function returns 28, total nr
of days in Feb.

TIA.
 
Isabelle said:
Does anyone has a function or routine that
can find out or calculate the exact nr of days in a month?

For example if month = 2 (feb)
that the function returns 28, total nr
of days in Feb.


Use the DatePart function.

However, the number of days in Feb depends on which year it
is, so you should also be provide a year as well as the
month:

DatePart("d", DateSerial(Year(somedate), Month(somedate) +1,
0))
 
Hello Isabelle

Sub NrOfDaysMonth(
Dim lNr As Lon

lNr = Day(DateSerial(Year(Date), 2 + 1, 1 - 1)
'where: 2+1 and 1-1 is a day before first day of next month,
So, to return last day in march use Day(DateSerial(Year(Date), 3 + 1, 1 - 1)) and so on

MsgBox lN
End Sub
 
Back
Top