Use this function to get the number of days in the specified month of a given year.
DaysInMonth (Month, Year)
Parameter |
Description |
Month |
Enter a month number from 1 to 12, with January being 1 and December being 12. The default is the current month. |
Year |
Enter a year. The default is the current year. |
The year value is only used when the month number is 2 (February). The result for February is different if the given year is a leap year. This function is typically used with the Month function. The Month function extracts the month number from a given date.
Here are some examples:
(Assume the current date is 07/01/09.)
Function |
Result |
Explanation |
DaysInMonth ( ) |
31 |
Defaults to the current date and returns the value 31 since July has 31 days. |
DaysInMonth (Month ("04/15/2009") ) |
30 |
The Month function extracts the number 04 (April) from the given date. The DaysInMonth function then determines that there are 30 days in April and returns that value. |
DaysInMonth(2, 2008) |
29 |
The year 2008 was a leap year, February had 29 days. Therefore the integer 29 is returned. |
© Copyright 2012, Oracle and/or its affiliates. All rights reserved. Legal notices.