Returns DateTime from Date, DateTime, or Time.
- If a
Timevalue is specified, which has no date component, returns a default date of12/30/1899. - If a
Datevalue, which has no time component, returns12:00:00 AM. - If the specified value is not a
Date,DateTime, orTimevalue, returns a blank.
Sample usage
DATETIME("4/1/2010 3:14") returns 4/1/2010 3:14:00 AM (24-hour time if no AM/PM)
DATETIME("4/1/2010 15:14") returns 4/1/2010 3:14:00 PM (24-hour time)
DATETIME("4/1/2010 3:14 PM") returns 4/1/2010 3:14:00 PM (12-hour time with AM/PM)
DATETIME(NOW()) returns the current date & time from a DateTime value. See also: NOW()
DATETIME("4/1/2010") returns 4/1/2010 12:00:00 AM (a Date value has no time component, so the default is used).
DATETIME(TODAY()) returns today's date at 12:00:00 AM from a Date value (TODAY() returns a Date value, which has no time component, so the default is used).
DATETIME("3:14") : returns 12/30/1899 3:14:00 AM (a Time value has no date component, so the default is used).
DATETIME(TIMENOW()) : returns 12/30/1899 at the current time (TIMENOW() returns a Time value, which has no date component, so the default is used).
Common problems
DATETIME("Good morning, Martin!") returns blank because the textual input isn't a recognized temporal type and so cannot be converted.
Syntax
DATETIME(when)
when- ADate,DateTime, orTimevalue.
Notes
To understand how your mobile device's locale or browser's language setting can impact the DateTime format, see Considerations for apps using Date, Time, and DateTime formats.
Some constant values, such as "MM/DD/YYYY", are evaluated as a Date value by AppSheet. Similarly, "000:00:00" is evaluated as a Duration value. This doesn't mean your spreadsheet data must use the same formats: the date and time formats in your spreadsheets are determined by the locale/language setting. Column will always be evaluated as the type of column. Additionally, you can convert data, both columns and string literals, to specific types using functions such as DATE(), TIME(), or DATETIME().
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.
See also
Considerations for apps using Date, Time, and DateTime formats