Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 28th, 2004, 08:57 AM
Authorized User
 
Join Date: Oct 2003
Location: Chicago, IL, USA.
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
Reply With Quote
  #2 (permalink)  
Old July 28th, 2004, 04:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
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
Reply With Quote
  #3 (permalink)  
Old July 28th, 2004, 04:13 PM
Authorized User
 
Join Date: Oct 2003
Location: Chicago, IL, USA.
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
Reply With Quote
  #4 (permalink)  
Old July 28th, 2004, 04:29 PM
Authorized User
 
Join Date: Oct 2003
Location: Chicago, IL, USA.
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
Reply With Quote
  #5 (permalink)  
Old July 28th, 2004, 06:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
Reply With Quote
  #6 (permalink)  
Old July 28th, 2004, 07:49 PM
Authorized User
 
Join Date: Oct 2003
Location: Chicago, IL, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:20 PM.


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