Excel VBA IsDate Function

VBA IsDate Function: The IsDate function in VBA returns a Boolean value indicating whether the given expression is interpreted as a VBA Date or not.

Syntax

IsDate (Expression)

Parameter

Expression (required) – This parameter represents the expression that you want to test for the Date.

Return

This function returns a Boolean value true if the specified expression is interpreted as a VBA Date else it returns False.

Example 1

Sub IsDate_Example1()
 Dim is_Date As Boolean
 Dim dat As Date
 dat = 42370
 is_Date = isDate(dat)
 ' The variable will return True.
 Cells(1, 1).Value = "The IsDate will return"
 Cells(1, 2).Value = is_Date
 End Sub 

Output

The IsDate will return TRUE
Excel VBA IsDate Function

Example 2

Sub IsDate_Example2()
 Dim is_Date As Boolean
 Dim dat As Date
 dat = #1/1/2016#
 is_Date = isDate(dat)
 ' The variable will return True.
 Cells(1, 1).Value = "The IsDate will return"
 Cells(1, 2).Value = is_Date
 End Sub 

Output

The IsDate will return TRUE
Excel VBA IsDate Function

Example 3

Sub IsDate_Example3()
 Dim is_Date As Boolean
 Dim dat
 'passing string value
 dat = "Jan 31 20120"
 is_Date = isDate(dat)
 ' The variable will return False.
 Cells(1, 1).Value = "The IsDate will return"
 Cells(1, 2).Value = is_Date
 End Sub 

Output

The IsDate will return FALSE
Excel VBA IsDate Function