当前位置: 首页 > news >正文

HIVE SQL时间函数

目录

  • current_timestamp()获取当前时间
  • unix_timestamp()获取当前时区的UNIX时间戳
  • from_unixtime()时间戳转日期函数
  • unix_timestamp(string date)日期转时间戳函数
  • 提取日期中的年月日时分秒
  • weekofyear (string date)日期转周函数
  • 日期比较函数datediff(string enddate, string startdate)
  • 日期增加/减少函数

current_timestamp()获取当前时间

select current_timestamp();

输出:2023-11-23 11:31:31.531

unix_timestamp()获取当前时区的UNIX时间戳

select unix_timestamp();

输出:1700710598

from_unixtime()时间戳转日期函数

select from_unixtime(1700710598);

输出:2023-11-23 11:36:38

unix_timestamp(string date)日期转时间戳函数

select unix_timestamp('2023-11-23 11:36:38');

输出:1700710598

提取日期中的年月日时分秒

> select year(current_timestamp());

输出:2023

select month(current_timestamp());

输出:11

select day(current_timestamp());

输出:23

select hour(current_timestamp());

输出:13

select minute(current_timestamp());

输出:39

select second(current_timestamp());

输出:25

weekofyear (string date)日期转周函数

select weekofyear(current_timestamp());

输出:47

日期比较函数datediff(string enddate, string startdate)

select datediff(current_timestamp(),'2023-11-20');

输出:3

日期增加/减少函数

date_add(string startdate, int days)
date_sub (string startdate, int days)

select date_add(current_timestamp(),3);

输出:2023-11-26

select date_sub(current_timestamp(),3);

输出:2023-11-20

http://www.lryc.cn/news/249032.html

相关文章:

  • linux磁盘的LVM、交换分区以及文件系统
  • 【HDFS】ActiveNamenodeResolver#getNamespaces 方法调用点梳理
  • 算法—双指针
  • ​[Oracle]编写程序,键盘输入n,计算1+前n项之和。测试案例:输入:10 输出:22.47​
  • 【视觉SLAM十四讲学习笔记】第三讲——旋转向量和欧拉角
  • 【UGUI】制作用户注册UI界面
  • 【UE】透视效果
  • 前端下载文件或者图片方式,window.open或者a标签形式
  • webpack配置scss loader
  • k8s有状态部署mysql主从(local pv持久化)
  • 下载并安装anaconda和VScode,配置虚拟环境,并使用VScode运行代码
  • 拼图 游戏
  • python循环语句和函数
  • php框架dcat-admin速查笔记
  • 【Java】文件I/O-文件内容操作-输入输出流-Reader/Writer/InputStream/OutputStream四种流
  • rocky8.9配置K8S集群kubernetes,centos同理
  • Linux下的文件IO之系统IO
  • iptables防火墙之SNAT与DNAT
  • Python与设计模式--命令模式
  • uni-app 自带返回方法onBackPress,返回上一级并且刷新页面内容获取最新的数据
  • python用YOLOv8对图片进行分类
  • Spring中@DependsOn 使用详解
  • android笔记 SELinux
  • vue3 keep-alive页面切换报错:parentComponent.ctx.deactivate is not a function
  • prompt提示
  • 边缘计算网关:智能制造的“智慧大脑”
  • HNCTF2022Week1 Reverse WP
  • 基于Python的面向对象分类实例Ⅱ
  • android手机莫名其妙卸载重装有残留数据
  • 【YOLOv5入门】目标检测