.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 Saturday 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 Saturday of week by given input date

This code example method will help to find the Saturday 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 GetEndSaturday(DateTime endDate)
string tmpEndSaturdayDate = endDate.ToString();
string FindSaturday;
for (int i = 0; i < 7; i++)
if (FindSaturday == DayOfWeek.Saturday.ToString())// return Saturday Date/Time
return tmpEndSaturdayDate;

VB.NET Language Code function

Public Shared Function GetEndSaturday(ByVal endDate As DateTime) As String
    Dim tmpEndSaturdayDate As String = endDate.ToString()
    Dim FindSaturday As String
    For i As Integer = 0 To 6
        If FindSaturday = DayOfWeek.Saturday.ToString() Then ' return Saturday Date/Time
            Exit For
        End If
    Return tmpEndSaturdayDate
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