VBA DateValue

DateValue Function Description

The VBA DateValue function returns a Date variable (or date serial value) for a string representing a date.

VBA DateValue Syntax

The syntax for the DateValue function in VBA is:

DateValue( date )

Parameters

date
A string representing a date e.g “2015-01-01”.

Example usage

Let’s look at some VBA DateValue function examples:

Dim d as Date, l as Long

d = DateValue("2015-01-01")
Debug.Print d
'Result: "2015-01-01"

l = DateValue("2015-01-01")
Debug.Print l 
'Result: 42005

Debug.Print DateValue("2015-01-01 10:00")
'Result: "2015-01-01"