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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date & Time restrictions

    I am trying to put date & time restrictions via IF statements. For example is today's date is before April 10 and the time is before 10:00am, you get a message that says: "You can see this yet."

    Thus far my code looks like this:

    Code:
    if (((Month(Date) & "/" & Day(Date) & "/" & Year(Date)) < "4/10/2006") and (Time() < "12:00:00 PM")) then %>
    
    <h4>You can't sign up until April 10.</h4>
    
    <% else %>
    
    <h4>You need not sign up.</h4>
    I was thinking it was my Time format but I have tried a few different things to no avail. Any ideas or suggestions would be greatly appreciated!

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Response.Write your date & time first to see if you have the same format.

    e.g.
    "12:00:00" is not equal to "12:00:00 AM"
    Same goes for dates. Check for the same format. m/dd/yyyy etc for US.



    This works for UK format dd/mm/yyyy
    Code:
    <%
    mydate = CDate("10/04/2006 10:00:00")
    If now() < mydate Then
    	Response.Write "The date is " & now() & ". You cannot view this until " & mydate
    Else
    	Response.Write "Hello"
    End If
    %>

  • #3
    New Coder
    Join Date
    Aug 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey, that is great! Thanks! It works!!


  •  

    Posting Permissions

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