Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

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

Copy
TO_DATE (string, format)

Arguments

string

String to be converted.

format

A string literal that defines the format of the string to be converted, 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:

Copy
select to_date ('02 Oct 2001', 'DD Mon YYYY'); to_date ------------ 2001-10-02 (1 row)