November 20, 2009

WinTask - DayOfDate$()


'
' DayOfDate$ - Return the day of the week for a given date
'
' Author - Joe Strazzere
'

Function DayOfDate$(TargetDate$)
    Local DayOfDate

    DayOfDate =((Weekday() + DateBetween("d",Date$(),TargetDate$)) mod 7)
    If DayOfDate < 1 then
        DayOfDate = DayOfDate + 7
    EndIf
    Select Case DayOfDate
        Case 1
            DayOfDate$ = "Sunday"
        Case 2
            DayOfDate$ = "Monday"
        Case 3
            DayOfDate$ = "Tuesday"
        Case 4
            DayOfDate$ = "Wednesday"
        Case 5
            DayOfDate$ = "Thursday"
        Case 6
            DayOfDate$ = "Friday"
        Case 7
            DayOfDate$ = "Saturday"
        Case Else
            DayOfDate$ = "I'm lost. I don't know what day "+Str$(DayOfDate)+" is."
        EndSelect
EndFunction

TargetDate$="11/21/2009"
TargetDay$=DayOfDate$(TargetDate$)
MsgBox(TargetDate$+" was a "+TargetDay$)