Skip to content
Last updated

Supported Time Formats in TD TIME FORMAT UDF

This is a summary of the time formats supported by the TD_TIME_FORMAT_UDF udf.

Formats

SyntaxDate or Time ComponentPresentationExamples
GEra designatorTextAD

yyyyYearYear1996
yyYearYear (2 digits)96
MMMMMonth in yearMonth long nameJuly
MMMMonth in yearMonth short nameJul
MM, MMonth in yearMonth number07
ww, wWeek in yearNumber06
DDD, DD, DDay in yearNumber189
dd, dDay in monthNumber10
EEEEDay in weekTextTuesday
E, EEEDay in weekText (short form)Tue
aAm/pm markerTextPM
HH, HHour in day (0-23)Number00
kk, kHour in day (1-24)Number24
KK, KHour in AM/PM (0-11)Number00
hh, hHour in AM/PM (1-12)Number12
mm, mMinute in hourNumber30
ss, sSecond in minuteNumber55
SSS, SS, SMillisecondNumber978
wyearWeek of the yearNumberTD_TIME_FORMAT(1582859260, 'wyear'
TD_TIME_FORMAT(1582859260, 'wyear', 'UTC'))
zzzzTime zoneZone long namePacific Standard Time, or GMT+01:00
zTime zoneZone short namePST, or GMT+01:00
ZTime zoneZone offset-0800
uDay number of week (1-7)Number1 (for Monday)

Example

This example formats a UNIX timestamp into a date formatted string. You can use the sample_datasets database for example to try it out:

SQL

SELECT 
  time,
  TD_TIME_FORMAT(time,
    'yyyy-MM-dd HH:mm:ss z')
FROM
  www_access LIMIT 1
;

Result

2012-01-01 00: 00: 00 UTC