Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate days of month

Tags:

vb.net

Is there any method for calculating the number of days in a month?

like image 873
Luca Romagnoli Avatar asked Apr 20 '10 14:04

Luca Romagnoli


1 Answers

Yes:

Const July As Integer = 7
Const Feb As Integer = 2

' daysInJuly gets 31. '
Dim daysInJuly As Integer = System.DateTime.DaysInMonth(2001, July)

' daysInFeb gets 28 because the year 1998 was not a leap year. '
Dim daysInFeb As Integer = System.DateTime.DaysInMonth(1998, Feb)

' daysInFebLeap gets 29 because the year 1996 was a leap year. '
Dim daysInFebLeap As Integer = System.DateTime.DaysInMonth(1996, Feb)

Credit goes to MSDN.

like image 58
Johnno Nolan Avatar answered Oct 06 '22 07:10

Johnno Nolan