DateValue

Purpose

Returns a Variant (Date).

Syntax

DateValue(date)

Description

The required date argument is typically a string expression representing a date from January 1, 100 through December 31, 9999. However, date can also be any expression that can represent a date, a time, or both a date and time, in that range.

If date is a string that includes only numbers separated by valid date separators, then DateValue recognizes the order for month, day, and year according to the Short Date format you specified for your system. DateValue also recognizes unambiguous dates that contain month names, either in long or abbreviated form. For example, in addition to recognizing 12/30/1991 and 12/30/91, DateValue also recognizes December 30, 1991 and Dec 30, 1991.

If the year part of date is omitted, then DateValue uses the current year from your computer's system date. If the date argument includes time information, then DateValue does not return it.

Note: If date includes invalid time information, for example, "89:98", then an error occurs.

Examples

Function Result
DateValue("01-01-2016") 01/01/2016
DateValue("01 Jan 2016") 01/01/2016
DateValue("01 January 16") 01/01/2016

For date, if the Calendar property setting is Gregorian, then the supplied date must be Gregorian. If the calendar is Hijri, then the supplied date must be Hijri.

If the supplied date is Hijri, then the argument date is a string representing a date from 1/1/100 (Gregorian Aug 2, 718) through 4/3/9666 (Gregorian Dec 31, 9999). The format of the date returned by the function will depend on your system locale.