So i have to pre-load a date drop down with the monday before today. I got this working, but was curious if there was a better way to do it.
By the way, I have tests for this and it works for each day of the week.
Thanks,
-Sometimes the answer to your question is the hack that works
By the way, I have tests for this and it works for each day of the week.
Code:
Public Shared Function GetMondayPriorTo(Optional ByVal dteToUse As Date = Nothing) As DateTime
If Not dteToUse.Date = Nothing Then
Dim dte As DateTime = dteToUse.Date.AddDays(-1 * (dteToUse.DayOfWeek - DayOfWeek.Monday))
Return IIf(dte.Date >= dteToUse.Date, dte.AddDays(-7), dte)
Else
Return Nothing
End If
End Function
Thanks,
-Sometimes the answer to your question is the hack that works