If you do that, Monday becomes Tuesday, Tuesday becomes Thursday, Wednesday
becomes Saturday etc.
What he is looking for is the date of the NEXT Sunday if 'Today' is NOT a
Sunday.
That would be something like:
if (CurrentDate.DayOfWeek == DayOfWeek.Sunday)
WKG = CurrentDate;
else
WKG = CurrentDate.AddDays(7 - (int)CurrentDate.DayOfWeek);
"Alun Harford" <de*****@alunharford.co.ukwrote in message
news:uD**************@TK2MSFTNGP02.phx.gbl...
Dave wrote:
>What is the C# Equivalent to VB's Weekday function? I'm trying to
convert this:
Select Case Weekday(CurrentDate)
Case 1 ' Sunday
WKG = CurrentDate
Case 2 ' Monday
WKG = CurrentDate + 6
Case 3 ' Tuesday
WKG = CurrentDate + 5
Case 4 ' Wednesday
WKG = CurrentDate + 4
Case 5 ' Thursday
WKG = CurrentDate + 3
Case 6 ' Friday
WKG = CurrentDate + 2
Case 7 ' Saturday
WKG = CurrentDate + 1
End Select
If you know an easier way to do this...I'm open.
Much easier. Because of the way the DayOfWeek enum is defined, you can
replace the whole switch statement with:
WKG = CurrentDate.AddDays((int)CurrentDate.DayOfWeek);
Alun Harford