Syntax

DATETIME(when)

Arguments

  • when (Date, DateTime, or Time)

Because temporal types are Text values with specific formats, any textual value may be supplied to DATETIME(), but non-temporal values will produce a blank result.

Return Value

DateTime: The converted value if when is recognized as a Date, DateTime, or Time value, or blank if not. If when is a Time value, which has no date component, a default date of 12/30/1899 is used. If when is a Date value, which has no time component, 12:00:00 AM is used.

Examples

DATETIME("4/1/2010 3:14") (24-hour time if no AM/PM): 4/1/2010 3:14:00 AM

DATETIME("4/1/2010 15:14") (24-hour time): 4/1/2010 3:14:00 PM

DATETIME("4/1/2010 3:14 PM") (12-hour time with AM/PM): 4/1/2010 3:14:00 PM

DATETIME(NOW()) : The current date & time from a DateTime value. See also NOW().

DATETIME("4/1/2010") : 4/1/2010 12:00:00 AM (a Date value has no time component, so a default is used).

DATETIME(TODAY()) : Today's date at 12:00:00 AM from a Date value (TODAY() returns a Date value, which has no time component, so a default is used).

DATETIME("3:14") : 12/30/1899 3:14:00 AM (a Time value has no date component, so a default is used).

DATETIME(TIMENOW()) : 12/30/1899 at the current time (TIMENOW() returns a Time value, which has no date component, so a default is used).

Potential Problems

DATETIME("Good morning, Martin!") : Returns blank because the textual input isn't a recognized temporal type and so cannot be converted.

See Also

DATE(), TIME()

Did this answer your question?