.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> DateTime >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Find the Sunday of week by given input date

Posted By:Rahul       Posted Date: September 24, 2009    Points: 10    Category: DateTime    URL: http://www.dotnetspark.com  

Find the Sunday of week by given input date

This code example method will help to find the Sunday of the given input date. This will help in the scenario when you are finding the off days or non working days of the week


C# Code

public static string GetStartSunday(DateTime startDate)
string tmpStartSundayDate = startDate.ToString();
string FindSunday;
for (int i = 0; i < 7; i++)
if (FindSunday == DayOfWeek.Sunday.ToString())// return Sunday Date/Time
return tmpStartSundayDate;


VB.NET Language Code function

Public Shared Function GetStartSunday(ByVal startDate As DateTime) As String
    Dim tmpStartSundayDate As String = startDate.ToString()
    Dim FindSunday As String
    For i As Integer = 0 To 6
        If FindSunday = DayOfWeek.Sunday.ToString() Then
            ' return Sunday Date/Time
            Exit For
        End If
    Return tmpStartSundayDate
End Function


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend