Question: Time comparisons

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

I want my web page to take the current time and either say "Good
Morning/Afternoon or Evening". Any ideas how I can do this? I tried this
but it's taking the times as strings...

Dim strMyTime As String = Now.ToShortTimeString

If strMyTime < "11:30 AM" Then
Response.Write("Good Morning")
ElseIf strMyTime > "11:30 AM" And strMyTime < "4:30 PM" Then
Response.Write("Good Afternoon")
Else
Response.Write("Good Evening")
End If


Thanks!
 
I want my web page to take the current time and either say "Good
Morning/Afternoon or Evening". Any ideas how I can do this? I tried
this but it's taking the times as strings...


Use the functions: Hour, Minute.

So something like

If Hour(Now()) < 11 and Minute(Now()) <= 30 then
lblTextBox.Text = "Good Morning"
End If

There's probably a more elegant want, but I'm brain dead.
 
Back
Top