IsDate Function
Tips >>ASP Functions

WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE


The IsDate function returns a Boolean value that indicates if the evaluated expression can be converted to a date. It returns True if the expression is a date or can be converted to a date; otherwise, it returns False. The IsDate VBScript function offers an easy way to validate a date in your server-side ASP code. As you might have expected the IsDate VBScript function takes only one parameter - date or string that represents any valid date/time format. The IsDate function will accept a date argument. If it's a valid date then the function will return True, if not it will return False.
Note:-
The IsDate function uses local setting to determine if a string can be converted to a date ("January" is not a month in all languages.)

The Syntax of IsDate function is :-

IsDate(expression)

Example#1 :-

Code :-
document.write(IsDate("April 22, 1947") & "<br />")
document.write(IsDate(#11/11/01#) & "<br />")
document.write(IsDate("#11/11/01#") & "<br />")
document.write(IsDate("Hello World!"))
Output :-
True
True
False
False

Example#2 :-

Code :-
<%
Dim theDate
theDate="04/21/2004" 'the date is American format
response.write IsDate(theDate)
%>
Output :-

Below is our code in action:
True

Example#3 :-

Code :-
<%
Dim theDate
theDate="25/2004"
response.write IsDate(theDate)
%>
Output :-

Below is our code in action:
False

Example#4 :-

Code :-
<%
Response.Write IsDate("January 13, 2003") '
Response.Write IsDate(#1/13/03#) '
Response.Write IsDate("This is not a date") '
Response.Write IsDate("10:55") '
%>
Output :-
True
True
False
True

 

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

Whatsapp Icon +91-9967648641

Whatsapp Icon +91-9967648641