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 – 毫秒时间戳
unix时间戳转换日期格式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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。