4 VB.NET Articles - How to find First Sunday of each month
Viewing Article

Current Rating :

How to find First Sunday of each month

Wednesday, February 09, 2011Posted by admin

Category:vb.Net Utilities
 

Here is the funtion in vb.net to find the first Sunday of each month Function GetFirstSunday(ByVal dt As Date) As String Dim inputDate As DateTime Dim outputDate As DateTime inputDate = Convert.ToDateTime(dt) ‘ Start at the day 1 outputDate = New DateTime(inputDate.Year, inputDate.Month, 1) ‘Loop through the month looking for the first Sunday For i As Int32 = 0 To Date.DaysInMonth(outputDate.Year, outputDate.Month) If outputDate.AddDays(i).DayOfWeek = DayOfWeek.Sunday Then outputDate = outputDate.AddDays(i) Exit For ‘We’re done.. get out of the loop End If Next GetFirstSunday = FormatDateTime(outputDate, DateFormat.LongDate) End Function

Hits:577      Current Rating :      No Of Ratings: 467      AuthorName: admin
  

Comment#23      Friday, February 11, 2011          Posted by Sumeet Singh

 
Hi this site is really great

Comments

Your Name  
 
Your Email( will not appear on page)  
Your Comments