-
Date Functions
I am assigning the current date to a text box, however, I want to always subtract three days if the day falls on a "Monday". I have the days of the week all worked out, but I can't seem to subtract the amount of days that I need.
If (ResultDate = "Monday") then
MyTextBox.Text = Today - 3
End If
Of course the above does not work, but that is the basic problem I am having. If anyone has an idea please let me know.
Thanks
-
Re: Date Functions
mytextbox.text = DateAdd("d", Now, -3)
-
Re: Date Functions
The function should actually be
Mydate = Format$(DateAdd("d", -3, Now), "dddd")
you can use format$ to format a date anyway you like check te help files.
-
Re: Date Functions
The WeekDay Function returns an integer representing the day of week referenced by a date.
dtMyDate = CDate(text1.Text) 'get date From Text Box
iDayOfWeek = WeekDay(dtMyDate) 'Ask for the day of week
If iDayOfWeek = 2 then 'If it's Monday
dtMyDate = dtMyDate - 3 'Subtract 3 days
text1.Text = Format(dtMyDate, "MM/DD/YYYY")
End If