flinksql下的时间日期格式转换

flinksql里面最常用的事情就是时间格式转换,比如各种时间格式转换成TIMESTAMP(3).
now() bigint-- CAST(TO_TIMESTAMP(log_time) as TIMESTAMP(3)) ,log_time=now()
localtimestamp timestamp(3)

timestamp – 不带括号数字表示timestamp(6)
now() 1403006911000 bigint – 毫秒时间戳数值 1528257600000
localtimestamp 1636272032500 timestamp(3) – 毫秒时间戳
timestamp(3) 1636272032500 – 毫秒时间戳
timestamp(9)
timestamp(6)

TIMESTAMP(9) TO_TIMESTAMP(BIGINT time)
TIMESTAMP(9) TO_TIMESTAMP(STRING time)
TIMESTAMP(9) TO_TIMESTAMP(STRING time, STRING format)
BIGINT TIMESTAMP_TO_MS(TIMTSTAMP time)
BIGINT TIMESTAMP_TO_MS(STRING time, STRING format)

TO_DATE(CAST(LOCALTIMESTAMP AS VARCHAR))

FROM_UNIXTIME(TIMESTAMP_TO_MS(localtimestamp)/1000, ‘yyyy-MM-dd HH:mm:ss’)

event_time 6点到6点
time_pt as cast(to_timestamp(eventTime - 6 * 3600 * 1000) as TIMESTAMP(3)) – 偏移6小时

date_format(to_timestamp(eventTime-636001000), ‘yyyy-MM-dd’) = dat

你可能感兴趣的:(数据仓库技术体系,flink,flink,sql,大数据)