Try
'if not exists, create first entry
Dim LastMonday As Long = GetPreviousDay(2)
LastMonday = DateUtils.SetDateAndTime(DateTime.GetYear(LastMonday), DateTime.GetMonth(LastMonday), _
DateTime.GetDayOfMonth(LastMonday), 23, 59, 59)
Log("LAST MONDAY MonthName: " & DateUtils.GetMonthName(LastMonday) & (DateTime.DateFormat="MM/d") & DateTime.Date(LastMonday))
Catch
Log(LastException)
End Try
Sub GetPreviousDay(DayOfWeek As Int) As Long
Dim day As Int = DateTime.GetDayOfWeek(DateTime.Now)
If day <> DayOfWeek Then
day = (day + 7 - DayOfWeek) Mod 7
End If
Dim d As Long = DateTime.Add(DateTime.Now, 0, 0, -day)
Return DateUtils.SetDate(DateTime.GetYear(d), DateTime.GetMonth(d), DateTime.GetDayOfMonth(d))
End Sub