IsDate Function
This page is specific to the Visual Basic for Applications (VBA) Language Reference for Office 2010.
Returns True if the expression is a date or is recognizable as a valid date or time; otherwise, it returns False.
Syntax
IsDate(expression)
The required expression argument is a Variant containing a date expression or string expression recognizable as a date or time.
Remarks
In Microsoft Windows, the range of valid dates is January 1, 100 A.D. through December 31, 9999 A.D.; the ranges vary among operating systems.
Example
This example uses the IsDate function to determine if an expression is recognized as a date or time value.
Dim MyVar, MyCheck
MyVar = "04/28/2014" ' Assign valid date value.
MyCheck = IsDate(MyVar) ' Returns True.
MyVar = "April 28, 2014" ' Assign valid date value.
MyCheck = IsDate(MyVar) ' Returns True.
MyVar = "13/32/2014" ' Assign invalid date value.
MyCheck = IsDate(MyVar) ' Returns False.
MyVar = "04.28.14" ' Assign valid time value
MyCheck = IsDate(MyVar) ' Returns True.
MyVar = "04.28.2014" ' Assign invalid time value.
MyCheck = IsDate(MyVar) ' Returns False.