Recent Posts

Monday, March 23, 2009

How to find the week number for a date of a month .net?

If you want to show the report in .net or asp .net application for a month and divide the data in weekly basis then you need to identify the week number to show the data accordingly. The following .net code allows you to find the week number for the given date of a month.

Dim userDate As DateTime
       Dim remain As Integer
       Dim noOfWeek As Integer

       userDate = DateTime.Parse("01/02/2010")

       noOfWeek = Math.DivRem(userDate.Day, 7, remain)

       If remain > 0 Then
           noOfWeek = noOfWeek + 1

       End If
       MessageBox.Show("The week no is :" & noOfWeek.ToString())

Enjoy coding

Related Posts by Categories

No comments:

Post a Comment