DateValue
DateValue
function to return a date in a specific
format.Syntax
The
DateValue
function returns a variant of subtype
Date
.
DateValue(date)
The required date argument is typically a string
expression representing a date from January 1, 100
through to December 31, 9999. The value date
can also be any expression that represents 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 the order for month, day, and year is recognized by DateValue
. The order is recognized according to the Short Date format that is
specified for the computer. Unambiguous dates containing month names, either in long or
abbreviated form are also recognized by DateValue
. For
example, in addition to recognizing 12/30/1991 and
12/30/91, December 30,
1991 and Dec 30, 1991 is also
recognized by DateValue
.
If the year
part of date is omitted, then DateValue
uses the current
year from the computer's system date. If the date argument includes time information, then
DateValue
does not return it.
If date includes invalid time information, for example, 89:98, then an error occurs.
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 that represents a date from 1/1/100 (Gregorian Aug 2, 718) through to 4/3/9666 (Gregorian Dec 31, 9999). The format of the date returned by the function depends on the system locale.
Example
This example returns "01/01/2016":
DateValue("01-01-2016")
This example returns "01/01/2016":
DateValue("01 Jan 2016")
This example returns "01/01/2016":
DateValue("01 January
16")