Teradata Timestamp/Date Formatting

Teradata Timestamp/Date Formatting

Teradata provides a way to display timestamps and dates in the desired format. Various character and character strings (Metacharacters) are available in Teradata which can be used along with FORMAT keyword to display timestamp/date in the required format.

Below tables show most of the metacharacters that can used with FORMAT keyword.

MetaCharacters

Description / Functionality

B

Display white space in formated timestamp

YYYY

Display year in four digits(example: 1987)

YY

Display year in two digits(example: 87)

MM

Display month of the year in number format(example: 12)

M3 or MMM

Display month in 3 characters format(example: Jun)

M4 or MMMM

Display full month name(example: June)

DD

Display day of the month in two digits(example: 30)

D3 or DDD

Display day of the year(example: 276)

HH

Display hour of the time in two digits(example: 17)

MI

Display minutes of the time in two digits(example: 59)

SS

Display seconds of the time in two digits(example: 58)

E3 or EEE

Display day of the week in 3 characters(example: Wed)

E4 or EEEE

Display full name of week day(example: Wednesday)

T

Display time in AM/PM format

: (Colon)

Other permitted character in format

- (Hyphen)

Other permitted character in format

/ (Backslash)

Other permitted character in format

. (Period)

Other permitted character in format

Note: IDE/JDBC Tools may not show formatted timestamp properly if output is not specifically casted to VARCHAR/CHAR.



All the below examples(after removing time formating part) can be used with DATE columns as well