TIMESTAMP_FORMAT Option

Sets the format used for timestamps retrieved from the database.

Allowed Values

A string composed of the symbols listed below.

Default

'YYYY-MM-DD HH:NN:SS.SSS'

Scope

Option can be set at the database (PUBLIC) or user level. When set at the database level, the value becomes the default for any new user, but has no impact on existing users. When set at the user level, overrides the PUBLIC value for that user only. No system privilege is required to set option for self. System privilege is required to set at database level or at user level for any user other than self.

Requires the SET ANY PUBLIC OPTION system privilege to set this option. Can be set temporary for an individual connection or for the PUBLIC role. Takes effect immediately.

Description

The format is a string using these symbols:

TIMESTAMP_FORMAT String Symbols

Symbol

Description

yy

2-digit year.

yyyy

4-digit year.

mm

2-digit month, or two digit minutes if following a colon (as in 'hh:mm').

mmm

3-character short form for name of the month of year

mmmm[m...]

Character long form for month name—as many characters as there are m's, until the number of m’s specified exceeds the number of characters in the month’s name.

dd

2-digit day of month.

ddd

3-character short form for name of the day of week.

dddd[d...]

Character long form for day name—as many characters as there are d's, until the number of d’s specified exceeds the number of characters in the day’s name.

hh

2-digit hours.

nn

2-digit minutes.

ss.SSS

Seconds (ss) and fractions of a second (SSS), up to six decimal places. Not all platforms support timestamps to a precision of six places.

aa

a.m. or p.m. (12-hour clock).

pp

p.m. if needed (12-hour clock.)

Each symbol is substituted with the appropriate data for the date being formatted. Any format symbol that represents character rather than digit output can be in uppercase, which causes the substituted characters also to be in uppercase. For numbers, using mixed case in the format string suppresses leading zeros.

Multibyte characters are not supported in format strings. Only single-byte characters are allowed, even when the collation order of the database is a multibyte collation order like 932JPN.

Related reference
DATE_FORMAT Option
RETURN_DATE_TIME_AS_STRING Option