Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2004, 08:57 AM
Authorized User
 
Join Date: Oct 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check to See if Current Time is between hours

Hey all,

I am almost positive I have seen this done before but I am struggling with it. I need to have a page that checks the current time and then depending on the time it will display certain things.

For example, if it is between 9AM and 11AM, it will show a link.

But I need it to check three different intervals (9-11, 1-4, 7-9). And if the current time is not between any of those hours (so like 6PM), then it just displays some text.

Any idea? Thanks again!

Mike

Michael W. Vollmer
__________________
Michael W. Vollmer
 
Old July 28th, 2004, 04:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

uhh...
Select Case Hour(Now)
  Case 9, 10, 11
    Response.Write("<a href=#">blah</a>")
  Case 1, 2, 3, 4
    Response.Write("<a href=#">blahblah</a>")
  Case 7, 8, 9
    Response.Write("This is just text")
  Case Else
    Response.Write("Dummy text - dunno what went wrong")
End Select

 - mega
 
Old July 28th, 2004, 04:13 PM
Authorized User
 
Join Date: Oct 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wow! I had a feeling it was something very simple like that but I just could not get it. I will try this later and let you know how it works. Thanks in advance!



Michael W. Vollmer
 
Old July 28th, 2004, 04:29 PM
Authorized User
 
Join Date: Oct 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just tried your example, but added 5 to the end of the line with 1, 2, 3, 4 so I could see if it works (it's only 4:30PM here) and it only shows the last line about the Dummy text. Any other ideas anybody?

Michael W. Vollmer
 
Old July 28th, 2004, 06:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

In that case use CInt() method and range bound If there.

Code:
Dim CurHr
CurHr = Hour(Now)

If Cint(CurHr) >= 1 and Cint(CurHr) <= 4 then 
    Response.write "<a href='thislink'>Thislink</a>"
ElseIf Cint(CurHr) >= 7 and Cint(CurHr) <= 8 then 
    Response.write "<a href='thatlink'>Thatlink</a>"
ElseIf Cint(CurHr) >= 9 and Cint(CurHr) <= 11 then
    Response.write "<a href='thatlink'>Thatlink</a>"
Else
    Response.write "Some Text"
End If
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old July 28th, 2004, 07:49 PM
Authorized User
 
Join Date: Oct 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That one seems to work! Thanks again sooo much. As always, you guys ROCK!

:D

Michael W. Vollmer





Similar Threads
Thread Thread Starter Forum Replies Last Post
check name of the current node element in xml arunagottimukkala XSLT 19 October 19th, 2007 04:44 AM
Please help to check the current node... darshil XSLT 1 May 9th, 2007 02:42 AM
Calculate total hours based on Time deepcover1 Access 1 April 5th, 2006 01:50 AM
how to check the current value and the previous va tllcll BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 October 24th, 2005 02:25 PM
sql - comparing current time suzila VB.NET 2002/2003 Basics 7 May 14th, 2004 12:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.