Returns the number of days in a month determined by the specified year and month.
[Visual Basic] Public Shared Function DaysInMonth( _ ByVal year As Integer, _ ByVal month As Integer _ ) As Integer [C#] public static int DaysInMonth( int year, int month ); [C++] public: static int DaysInMonth( int year, int month ); [JScript] public static function DaysInMonth( year : int, month : int ) : int;
The value is the number of days in the month specified by the year and month arguments.
Exception Type | Condition |
---|---|
ArgumentException | If the month is less than 1 or greater than 12. |
The DaysInMonth method is used to retrieve the number of days in a month where the month and year are specified.
The month value is an integer one through twelve (1 through 12). For example: for the month of February (month equals 2), the returned value is 28 or 29, depending upon whether the year is a leap year.
DateTime Structure | DateTime Members | System Namespace | Int32 | Calendar