15.00 - TO_CHAR(DateTime) - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)

TO_CHAR(DateTime)

Purpose  

Converts a date_timestamp_value to a character string.

Syntax  

where:

 

Syntax element …

Specifies …

TD_SYSFNLIB

the name of the database where the function is located.

date_timestamp_value

a datetime or interval argument.

format_arg

an optional character argument.

For valid format_arg values, see “TO_DATE” on page 801.

format_arg formats the date, time stamp, or interval value. If format_arg is omitted, a default format is used.

If format_arg is not valid, an error is returned.

ANSI Compliance

This is a Teradata extension to the ANSI SQL:2011 standard.

Invocation

TO_CHAR(DateTime) is an embedded services system function. For information on activating and invoking embedded services functions, see “Embedded Services System Functions” on page 24.

Argument Types and Rules

Expressions passed to this function must have the following data types:

  • date_timestamp_value = DATE, TIME, TIME WITH TIME ZONE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, or an Interval data type, such as INTERVAL YEAR TO MONTH.
  • format_arg = CHAR or VARCHAR
  • Result Type

    TO_CHAR(DateTime) is a scalar function whose return data type is VARCHAR CHARACTER SET UNICODE.

    Example  

    The following query:

    SELECT TO_CHAR(DATE '2003-12-23', 'DD-MON-YYYY'); 

    returns a result of '23-DEC-2003'.