0
点赞
收藏
分享

微信扫一扫

HQL时间查询总结(HIVE)

爪哇驿站 2022-01-21 阅读 66

--时间格式转为时间戳10位数字,时分秒的跟没有的转换结果不一样
select unix_timestamp('2021-12-03')  ---不行,返回结果是null
select unix_timestamp('2021-12-03 01:10:00')
select unix_timestamp('2021-12-03','yyyy-MM-dd')
select unix_timestamp('2021-12-03 01:10:00','yyyy-MM-dd')
select unix_timestamp('2021-12-03 01:10:00','yyyy-MM-dd HH:mm:ss')

--时间戳不能加''号/from_unixtime把时间戳转换成时间格式
select from_unixtime(1638465000)
select from_unixtime(1638465000,'yyyy-MM-dd')
select from_unixtime(1638465000,'yyyy-MM-dd HH:mm:ss') 

--转时间戳再转时间格式(转化成其他时间格式)
select from_unixtime(1638465000,'yyyyMMdd')
select from_unixtime(unix_timestamp('2021-12-03 01:10:00','yyyy-MM-dd HH:mm:ss'))
select from_unixtime(unix_timestamp('2021-12-03 01:10:00','yyyy-MM-dd HH:mm:ss'),'yyyyMMdd')
select from_unixtime(unix_timest

举报

相关推荐

0 条评论