to_date()

Scalar. Converts a given value to a date.

Syntax

to_date ( value )
to_date ( value, format )

Parameters

value

A string, float, long, or date. Strings must be in the format specified by the format argument. Numeric values represent the number of seconds from the epoch (midnight, January 1, 1970 UTC).

format

A format string. Only valid if the value is a string. Must be one of the format codes for a date. See "Date/Time Format Codes" for more information.

Usage

Converts a given value to a date. The function takes a float, a long, or a string (and associated format string) as its argument, and the function returns a date. Note that the function can also take a date as its argument, but it will return the same date.

Examples

to_date('02/19/2010 10:15', '%m/%d/%Y %H:%M') returns 2010-02-19 10:15:00.

to_date('07/19/2010 10:15 -07.00', 'MM/DD/YYYY HH:MI TZH:TZM') returns 2010-07-19 03:15:00.