Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-08-2011, 03:53 PM   PM User | #1
scotthrogers
New to the CF scene

 
Join Date: Nov 2011
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
scotthrogers is an unknown quantity at this point
Conditional time calculation

I have the following script that is used to disable logins from 9am to 11:30am EST excluding Saturday and Sundays. The script seems to be working from 10:30am EST to 11:30am EST excluding sat/sun but its not working from 9am to 10:30am EST.

Anyone have ideas for me?

Here is the scpirt
Code:
<%
'get PST time
ServerToOrgHourOffset = 2 ' Daylight saving change Set to three before Nov and set to 2 after
mvarOrgCurDtTime = DateAdd("H", mintServerToOrgHourOffset, Now())
mvarOrgCurDt = DateValue(mvarOrgCurDtTime)
mvarOrgCurDtDay = Weekday(Date)
mvarOrgCurTime = TimeValue(mvarOrgCurDtTime)
mvarOrgCurTimeHour = Hour(mvarOrgCurTime) - 2 
%>      
<% 
Response.Write  mvarOrgCurTime
Response.Write  mvarOrgCurDtDay
Response.Write mvarOrgCurTimeHour 
%>    
          
            <P>&nbsp;</P></td><td width="732">
    <% if (mvarOrgCurTime  < "11:30:00 AM")And mvarOrgCurTimeHour >= 7 And mvarOrgCurDtDay <> 7 And mvarOrgCurDtDay <> 1 then   %>
login box is disabled

Code:
<% Else %>
Show login box

Code:
<% End If %>
scotthrogers is offline   Reply With Quote
Old 11-08-2011, 07:35 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
IN VBScript code, date and time constants are *NOT* surrounded by "....". Instead, you need to use #...#.

SO:
Code:
<% 
if mvarOrgCurTime  < #11:30:00 AM# And mvarOrgCurTimeHour >= 7 _
   And mvarOrgCurDtDay <> 7 And mvarOrgCurDtDay <> 1 then   
%>
When you use a string ("...") you get a string comparison. And "9" is not less than "11".
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
scotthrogers (11-08-2011)
Reply

Bookmarks

Tags
asp, conditional time, timevalue

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:58 PM.


Advertisement
Log in to turn off these ads.