Visual Basic Language Reference  

IsDate Function

Returns a Boolean value indicating whether an expression can be converted to a date.

Public Function IsDate(ByVal Expression As Object) As Boolean

Parameter

Expression
Required. Object expression.

Remarks

IsDate returns True if the expression is of type Date or is a string convertible to type Date; otherwise, it returns False.

Example

This example uses the IsDate function to determine if several variables can be converted to dates.

Dim MyDate, YourDate As Date
Dim NoDate As String
Dim MyCheck As Boolean
MyDate = "February 12, 1969"
YourDate = #2/12/1969#
NoDate = "Hello"
MyCheck = IsDate(MyDate)   ' Returns True.
MyCheck = IsDate(YourDate)   ' Returns True.
MyCheck = IsDate(NoDate)   ' Returns False.

See Also

IsArray Function | IsDBNull Function | IsError Function | IsNothing Function | IsNumeric Function | IsReference Function | Object Data Type | Date Data Type | TypeName Function