Converts a string to a date value by interpreting it according to the specified format pattern.
Syntax
1to_date(<text>, <format_pattern>)
Arguments
Required
<text>: The string to convert to a date.
<format_pattern>: A text pattern that describes the format of <text>. For supported pattern characters and modifiers, see TO_CHAR.
Returns
Returns a date value.
Returns NULL if either argument is NULL.
Considerations
TO_DATE converts source strings in formats that a direct cast can’t handle. For most standard date formats, cast the string directly to date instead.
Template characters in the pattern that don’t match a date field are skipped in the input string. For example, literal separators such as - or / in the format pattern skip the corresponding characters in the input.
YYYY can’t process a year with more than four digits. Use a non-digit separator after the year for five-or-more digit years — for example, to_date('20000-11-30', 'YYYY-MM-DD').
Examples
Parse a Date from a Long-Form String
Convert a written-out date string to a date value.