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

结果

相关推荐
skywalk816312 小时前
lightharness第一次大规模开hive任务卡成功
人工智能·hive·agent·deepseek·lightharness
大今野13 小时前
2026 专转本计算机|大数据关键技术:Hadoop、MapReduce、NoSQL 与处理流程(附例题)
大数据·hadoop·mapreduce·专转本
SeanQhl1 天前
鲲鹏开发套件综合实战
hadoop·性能调优·openeuler·鲲鹏devkit·应用迁移
崖边看雾2 天前
Hive 手册:建表、分区、查询与调优实战指南
数据仓库·hive·hadoop
AllData公司负责人2 天前
实战二:AllData大模型与AI数据底座-数据传输平台-DBSyncer,搭建 Http 接口同步至 Doris,API 业务数据自动拉取入数仓
大数据·数据库·数据仓库·人工智能·算法·http·doris
CoderYanger5 天前
Java EE 进阶:11. SpringBoot 统一功能处理(第二弹):DispatcherServlet 源码分析+适配器模式
java·数据库·hive·spring boot·面试·java-ee·mybatis
starzy19907 天前
Structured Streaming 模块与编程模型:引擎内部到底由什么组成
大数据·hadoop·hdfs
AI源码9 天前
基于 Hadoop 和 Hive 的旅游景区数据的分析与可视化系统
hive·hadoop·旅游
DataY轻量数据平台10 天前
任务调度的三种模式:什么时候跑、按什么顺序跑、等谁跑完
数据仓库·etl
演艺大赏10 天前
三个坑连环套:一次 NameNode 起不来,从 JournalNode 未格式化查到配置里多了个挂载点
大数据·hadoop