hive时间函数

一、随机示例(想到哪里写哪里)

1.系统时间函数

查询

sql 复制代码
select 
     current_timestamp --当前格式化时间
    ,current_date      --当前格式化日期
    ,unix_timestamp()  --当前unix时间戳

结果:

2.时间函数转换

查询

sql 复制代码
--将时间戳转化为格式化时间
select 
     from_unixtime(1725865044)
    ,from_unixtime(1725865044,'yyyy-MM-dd')
    ,from_unixtime(1725865044,'yyyy-MM')
    ,from_unixtime(1725865044,'dd')

结果

查询

sql 复制代码
--时间格式化为日期
select to_date('2024-09-09 14:57:24')

结果

查询

sql 复制代码
--日期格式化
select 
     date_format('2024-09-09 14:57:24','yyyy-MM-dd')
    ,date_format('2024-09-09','yyyy-MM')
    ,date_format('2024-09-09','yyyy')

结果

3.时间函数

查询

sql 复制代码
select 
     year(current_date)        --年
    ,quarter(current_date)     --季度
    ,month(current_date)       --月
    ,day(current_date)         --日
    ,hour(current_timestamp)   --时
    ,minute(current_timestamp) --分
    ,second(current_timestamp) --秒

结果

相关推荐
嘉禾望岗50319 小时前
hive join优化和数据倾斜处理
数据仓库·hive·hadoop
yumgpkpm19 小时前
华为鲲鹏 Aarch64 环境下多 Oracle 数据库汇聚操作指南 CMP(类 Cloudera CDP 7.3)
大数据·hive·hadoop·elasticsearch·zookeeper·big data·cloudera
忧郁火龙果20 小时前
六、Hive的基本使用
数据仓库·hive·hadoop
忧郁火龙果21 小时前
五、安装配置hive
数据仓库·hive·hadoop
chad__chang1 天前
dolphinscheduler安装过程
hive·hadoop
莫叫石榴姐2 天前
字节数开一面
大数据·数据仓库·职场和发展
ajax_beijing2 天前
hadoop的三副本数据冗余策略
大数据·hadoop·分布式
weixin_307779132 天前
在 Microsoft Azure 上部署 ClickHouse 数据仓库:托管服务与自行部署的全面指南
开发语言·数据库·数据仓库·云计算·azure
weixin_307779133 天前
AWS Redshift 数据仓库完整配置与自动化管理指南
开发语言·数据仓库·python·云计算·aws