Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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 %>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,919
    Thanks
    79
    Thanked 4,423 Times in 4,388 Posts
    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.

  • Users who have thanked Old Pedant for this post:

    scotthrogers (11-08-2011)


  •  

    Tags for this Thread

    Posting Permissions

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