Results 1 to 4 of 4

Thread: [RESOLVED] Simple newbie ASP question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    180

    Resolved [RESOLVED] Simple newbie ASP question

    Hi,

    I could do this very easily with .NET, but my client wants it in basic ASP which I have no experience of.

    I hope someone can help.

    If the time is between 00:00 and 11:59 then write "Good Morning"
    ElseIf the time is between 12:00 and 18:00 then write "Good Afternoon"
    ElseIf the time is between 18:01 and 23:59 then write "Good Evening"

    Thanks!

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Simple newbie ASP question

    Something like this should work
    Code:
    <%
    Dim dteTime
    
    dteTime = time
    
    If dteTime > #18:00:00# Then
    	Response.Write("Good Evening")
    ElseIf dteTime > #12:00:00# Then
    	Response.Write("Good Afternoon")
    Else
    	Response.Write("Good Morning")
    End If
    %>

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    180

    Re: Simple newbie ASP question

    Is it possible to get the output into a function, so for example I could use

    <%=timeOfDay%>, Welcome to our site!

    <%Private Function timeOfDay as String
    Dim dteTime

    dteTime = time

    If dteTime > #18:00:00# Then
    Return "Good Evening"
    ElseIf dteTime > #12:00:00# Then
    Return "Good Afternoon"
    Else
    Return "Good Morning"
    End If
    %>

    Have I got the syntax correct?

    Thanks

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Simple newbie ASP question

    Code:
    <%=timeOfDay%>, Welcome to our site!
    
    <%
    Function timeOfDay()
    Dim dteTime
    
    	dteTime = time
    
    	If dteTime > #18:00:00# Then
    		timeOfDay = "Good Evening"
    	ElseIf dteTime > #12:00:00# Then
    		timeOfDay = "Good Afternoon"
    	Else
    		timeOfDay = "Good Morning"
    	End If
    End Function
    %>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width