Updated on 2022-11-18 GMT+08:00

Teradata Function

The following functions provide the Teradata SQL. capability.

String Functions

  • char2hexint(string)

    Description: Returns the hexadecimal representation of the UTF-16BE encoding of a string.

  • index(string, substring)

    Description: Same as strpos().

Date Functions

The functions in this section use format strings that are compatible with the Teradata datetime function. The following table describes the supported format specifiers based on the Teradata reference manual:

Specifier

Description

- / , . ; :

Ignore punctuation

dd

Day (1 to 31) in a month

hh

Hour (1 to 12) in a day

hh24

Hour (0 to 23) in a day

mi

Minute (0 to 59)

mm

Month (01 to 12)

ss

Second (0 to 59)

yyyy

Four-digit year

yy

Two-digit year

Case-insensitive is not supported. All specifiers must be in lower case.

  • to_char(timestamp, format)

    Description: Outputs a timestamp as a string in a specified format.

    select to_char(timestamp '2020-12-18 15:20:05','yyyy/mmdd hh24:mi:ss');-- 2020/1218 15:20:05
  • to_timestamp(string, format)

    Description: Parses a string to a timestamp in a specified format.

    select to_timestamp('2020-12-18 15:20:05','yyyy-mm-dd hh24:mi:ss'); -- 2020-12-18 15:20:05.000
  • to_date(string, format)

    Description: Converts a string to a date in the specified format.

    select to_date('2020/12/04','yyyy/mm/dd'); -- 2020-12-04