Converts text to a date with time.
Sample usage
PARSE_DATETIME("%f", DateTimeText)
Syntax
PARSE_DATETIME(format_string, text)
Parameters
format_string
- See Supported Format Elements For DATETIME for a list of format elements that this function supports.
text
- a text representation of a date.
Return data type
Date & Time
Examples
In this example, DateTimeText is a field containing a text date and time. The result of applying PARSE_DATETIME
with the correct format_string is a Date & Time value.
Example formula | Input | Output |
---|---|---|
PARSE_DATETIME("%d/%m/%y %H:%M:%S", DateTimeText) |
25/12/08 12:12:12 |
2008-12-25 12:12:12 |
The following example parses the DateTimeText field containing a date in a natural language format as a Date & Time value.
Example formula | Input | Output |
---|---|---|
PARSE_DATETIME('%A, %B %e, %Y', DateTimeText) |
Wednesday, December 19, 2018 | 2018-12-19 00:00:00 |
Notes
When using PARSE_DATETIME
, keep the following in mind:
- Unspecified fields. Any unspecified field is initialized from 1970-01-01.
- Case insensitive names. Names, such as Monday, February, and so on, are case insensitive.
- Whitespace. One or more consecutive white spaces in the format string matches zero or more consecutive white spaces in the date string. In addition, leading and trailing white spaces in the date string are always allowed -- even if they are not in the format string.
- Format precedence. When two (or more) format elements have overlapping information (for example both
%F
and%Y
affect the year), the last one generally overrides any earlier ones.
This function supports format elements, but does not have full support for
%Q, %a, %A, %g, %G, %j, %u, %U, %V, %w, and %W.
See Supported Format Elements For DATETIME for a list of format elements that this function supports.