VBScript IsDateFunction
Complete VBScript Reference Manual
The IsDate function returns a Boolean value indicating whether an 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.
Note:The IsDate function uses local settings to detect whether a string can be converted to a date (in all languages, "January" is not a month).
Syntax
IsDate(expression)
| Parameter | Description |
|---|---|
| expression | Required. The expression to be evaluated. |
Example 1
Valid date:
<script type="text/vbscript">
document.write(IsDate("April 22, 1947"))
document.write("<br />")
document.write(IsDate(#01/31/10#))
</script>
document.write(IsDate("April 22, 1947"))
document.write("<br />")
document.write(IsDate(#01/31/10#))
</script>
The above example outputs:
True
True
True
Try it »
Example 2
Invalid date:
<script type="text/vbscript">
document.write(IsDate("#01/31/10#"))
document.write("<br />")
document.write(IsDate("52/17/2010"))
document.write("<br />")
document.write(IsDate("Hello World!"))
</script>
document.write(IsDate("#01/31/10#"))
document.write("<br />")
document.write(IsDate("52/17/2010"))
document.write("<br />")
document.write(IsDate("Hello World!"))
</script>
The above example outputs:
False
False
False
False
False
Try it »
Complete VBScript Reference Manual Other extensions