VBA DateValue function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

DateValue Function Description

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

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"

Simply the best place to learn Excel VBA