I have a basic script that was working no problem for a year. Recently, I've tried to add an IF
statement to it, so if the current date is a particular day of the year i.e. January 18, then do not Msgbox. I thought it would be fairly straight forward, but ran into Sub or Function not defined
on the first line of the IF statement that I cannot seem to resolve on my own:
If Not CStr(Date()) Like "1/18/*" _
And Not CStr(Date()) Like "2/15/*" _
And Not CStr(Date()) Like "12/31/*" Then
MsgBox "perform task"
Else
MsgBox "do not perform task"
End If
Can someone tell me what I am missing?
There is no Like operator in VBScript. One way to achieve what you are trying to do would be:
MonthAndDay = Month(Date) & "/" & Day(Date)
If MonthAndDay <> "1/18" _
and MonthAndDay <> "2/15" _
and MonthAndDay <> "12/31" Then
MsgBox "perform task"
Else
MsgBox "do not perform task"
End If