Week Number from date in .Net

Hello friends,

I will show an example that find out week no. from date in VB.net.

Step 1: Imports System.Globalization in your page.
Step 2 : Now in your Page_load event of default.aspx page,paste the following code

Dim ciCurr As CultureInfo = Nothing
Dim intweekNo As Integer = 0
Dim intCalendarWeekRule = 0
Dim dteDate as DateTime=Now.Date
Try
ciCurr = CultureInfo.CurrentCulture
intweekNo = ciCurr.Calendar.GetWeekOfYear(dteDate, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
lblOutput.Text=intweekNo.ToString()
Catch ex As Exception
lblMessage.Text=ex.Message
Finally
End Try
Step:3 When you run the following code you will get the weekno. of current date.

Comments

Popular posts from this blog

String Function in SQL-Substring,Reverse,CharIndex

Difference Between ArrayList and Generic.List C#/VB.Net

How to Use Not IN operator