Public Function GetWeeksInYear(ByVal dayofsunday As DateTime) As Integer
Dim dayofthursday As DateTime = dayofsunday.AddDays(-3)
Dim yearno As Integer = dayofthursday.Year
Dim firstday As DateTime = "01-Jan-" & yearno.ToString
Dim totalweeks As Integer = 0
If firstday.DayOfWeek = DayOfWeek.Thursday Then
totalweeks = 53
ElseIf Date.IsLeapYear(yearno) = True _
And firstday.DayOfWeek = DayOfWeek.Wednesday Then
totalweeks = 53
Else
totalweeks = 52
End If
Return totalweeks
End Function
Monday, April 20, 2009
VB.Net - Get Weeks In a Year
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment