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) --秒

结果

相关推荐
RestCloud4 小时前
数据同步零中断:ETL服务宕机重启后异常任务自动重跑
数据仓库·mysql·etl·etlcloud·数据传输·etl工具
泡干脆面就番茄7 小时前
Hive分区表与分桶表:大数据查询提速的第一把钥匙
大数据·数据仓库·hive·hadoop
chde2Wang8 小时前
hadoop部署错误-namenode address dfs.namenode.servicerpc-address not configured
java·大数据·hadoop
SelectDB技术团队1 天前
Apache Doris 基于 Lance 的向量检索深度解析
数据库·数据仓库·数据分析·湖仓一体·apache doris·lakehouse·多模湖仓
泡干脆面就番茄1 天前
Hive-DML:Load-Insert-Export-Import四种数据进出方式
大数据·数据仓库·hive·hadoop
SelectDB技术团队1 天前
日志场景 Elasticsearch 替换实操:建表、索引、写入链路与查询改写的完整参数
大数据·数据库·数据仓库·elasticsearch·全文检索·日志分析·apache doris
省钱兄--zs2 天前
深圳24小时自助健身房软硬件解决方案实战指南与开发流程详解
java·数据仓库·spring boot·小程序·架构
省钱兄--zs2 天前
无人自助拼豆系统架构设计与功能实现落地部署全流程实战指南
java·数据仓库·spring boot·系统架构·需求分析
棣廷2 天前
初识Hive(1)
数据仓库·hive·hadoop
Francek Chen2 天前
【大数据处理与分析】数据仓库Hive:07 Hive HA基本原理
大数据·数据仓库·hive·hadoop·数据分析