TO_DATE
TO_DATE converts a date represented in a character string to a DATE data type.
The second argument is a format string that indicates how the character string should be parsed to create the date value.
Syntax
TO_DATE (string, format)
Arguments
- string
-
String to be converted.
- format
-
A string literal that defines the format of the output, in terms of its date parts. For a list of valid formats, see Datetime Format Strings.
Return Type
TO_DATE returns a DATE, depending on the format value.
Example
The following command converts the date 02 Oct 2001
into the default
date format:
select to_date ('02 Oct 2001', 'DD Mon YYYY'); to_date ------------ 2001-10-02 (1 row)