The
CDate and
Date functions are equivalent to DateValue.
Description
Creates a DateValue value from the information provided.
Arguments
number is a value representing the number of days starting from December 30, 1899. number can be positive or negative, and is truncated if it is fractional.
string is a text string representing a date; for example, "September 20, 1999".
dateTime is a DateTime value.
year is a whole number representing a year; month is a whole number representing a month; day is a whole number representing a day of the month.
Action
DateValue (string) returns a Date value given a string that represents a date from January 1, 100 through December 31, 9999.
DateValue (number) returns a Date value given a number of days starting from December 30, 1899. Number can be positive or negative, and truncated if fractional.
DateValue (dateTime) returns the date portion of a given DateTime value.
DateValue (YYYY, MM, DD) returns a Date value given numeric arguments of the year, month and day.
Examples
DateValue ("Dec 31, 1999")
Returns the Date value for Dec. 31, 1999.
DateValue (50)
Returns the Date value for February 18, 1900.
DateValue (#Oct. 20, 1999 12:02pm#)
Returns the Date value for October 20, 1999.
DateValue (1930, 7, 30)
Returns the Date value for July 30, 1930.
Comments
You can use the
IsDate function to check if a String argument can be converted to a Date before doing the actual conversion. That way, if the conversion cannot be done, you can handle the situation appropriately.