Why does this code execute a message box displaying, “Late”? I would have expected, “Today”, but I am lacking sleep too.
Dim oneDay as Integer
Dim yesterday as new date
Dim today as new date
Dim tomorrow as new date
oneDay = ( 24 * 60 * 60 )
yesterday.TotalSeconds = today.TotalSeconds - oneDay
tomorrow.TotalSeconds = today.TotalSeconds + oneDay
select case today.ShortDate
case Is <= yesterday.ShortDate
msgbox "Late"
case today.ShortDate
msgbox "Today"
case tomorrow.ShortDate
msgbox "Tomorrow"
end select
Also, why not simply use the Day property instead of totalSecond ?
Dim oneDay as Integer
Dim yesterday as new date
yesterday.Day = yesterday.day-1
system.DebugLog yesterday.ShortDate
Dim today as new date
system.DebugLog today.ShortDate
Dim tomorrow as new date
tomorrow.Day = tomorrow.day+1
Dim yesterday as new date
Dim tomorrow as new date
yesterday.day= today.day-1
tomorrow.day = today.day+1
select case today.sqldate
case Is <=yesterday.sqldate
msgbox "Late"
case today.today.sqldate
msgbox "Today"
case tomorrow.sqldate
msgbox "Tomorrow"
end select
and <= makes sense… it is not = yesterday… is is yesterday or BEFORE (ie. its late)
BUT… it will never work… as you are ALWAYS comparing to TODAY
[quote=193359:@Dave S]or why not compare the SQLDate string property?
Dim yesterday as new date
Dim tomorrow as new date
yesterday.day= today.day-1
tomorrow.day = today.day+1
select case today.sqldate
case Is <=yesterday.sqldate
msgbox "Late"
case today.today.sqldate
msgbox "Today"
case tomorrow.sqldate
msgbox "Tomorrow"
end select
[/quote]
SQLDate is what I needed.
I’m surprised everyone uses .Day, since I thought it was considered unreliable. Maybe that has since changed.
Exactly.
[quote=193359:@Dave S]
BUT… it will never work… as you are ALWAYS comparing to TODAY[/quote]
Right. That was just for example purposes.