Date diff example 2

this example takes a given date and then works out whether a user is under a certain age , in this case 16 years and then prints a message on the screen depending on whether this is true or false . You could redirect users to different pages instead .

<%
Dim date1 , date2 , strDateDiff
date1 = Now()
date2 = "18/10/1974"
strDateDiff = DateDiff("yyyy" , date2 , date1 )
If strDateDiff < 16 Then
Response.Write "Sorry you are under age"
Else
Response.Write "You may enter"
End If
%>

 

Sponsors