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
break;
}
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
Next
Return tmpEndSaturdayDate
End Function