Mega Code Archive

 
Categories / VB.Net / Development
 

Calendar GetWeekOfYear returns the week of the year that includes the date in the specified DateTime value

Imports System.Globalization Module Example    Public Sub Main()       Dim dfi As DateTimeFormatInfo = DateTimeFormatInfo.CurrentInfo       Dim date1 As Date = #1/1/2011#       Dim cal As Calendar = dfi.Calendar       Console.WriteLine("{0:d}: Week {1} ({2})", date1,                         cal.GetWeekOfYear(date1, dfi.CalendarWeekRule,                                           dfi.FirstDayOfWeek),                         cal.ToString().Substring(cal.ToString().LastIndexOf(".") + 1))    End Sub End Module