...

View Full Version : Date & Time restrictions



bean262
03-29-2006, 04:24 PM
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:


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!

degsy
03-29-2006, 05:09 PM
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


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

bean262
03-29-2006, 07:29 PM
hey, that is great! Thanks! It works!! :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum