1、current_timestamp() -- 获取时间
2022-10-09 16:00:24.189
2、unix_timestamp() -- 获取时间戳
1665302498
3、select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') -- 获取指定格式的日期
2022-10-09 16:03:00
1、SELECT FROM_UNIXTIME(1664208000,'yyyy-MM-dd') -- 时间戳转日期
2、select unix_timestamp() -- 获取当前时间戳
3、select unix_timestamp('2021-11-11 11:11:11'); --1636600271 -- 日期转时间戳
unix_timestamp() -- 输入日期参数 输入的时间格式必须符合 yyyy-MM-dd HH:mm:ss
1、from_unixtime() -- 将时间戳转化为指定的时间格式
2、select from_unixtime(1628956800,'yyyy-MM-dd'); -- 2021-08-15
3、select from_unixtime(1628956800,'yyyy-MM-dd HH-mm'); -- 2021-08-15 00-00
TRUNC函数为指定元素而截去的日期值。
其具体的语法格式如下:
TRUNC(date[,fmt])
其中:date 一个日期值
fmt 日期格式,该日期将由指定的元素格式所截去。忽略它则由最近的日期截去
如果当日日期是:2011-3-18
select trunc(sysdate) from dual --2011-3-18 今天的日期为2011-3-18
select trunc(sysdate, 'mm') from dual --2011-3-1 返回当月第一天.
select trunc(sysdate,'yy') from dual --2011-1-1 返回当年第一天
select trunc(sysdate,'dd') from dual --2011-3-18 返回当前年月日
select trunc(sysdate,'yyyy') from dual --2011-1-1 返回当年第一天
select trunc(sysdate,'d') from dual --2011-3-13 (星期天)返回当前星期的第一天
select trunc(sysdate, 'hh') from dual --2011-3-18 14:00:00 当前时间为14:41
select trunc(sysdate, 'mi') from dual --2011-3-18 14:41:00 TRUNC()函数没有秒的精确
TRUNC(number,num_digits)
Number 需要截尾取整的数字。
Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。
TRUNC()函数截取时不进行四舍五入
select trunc(123.458) from dual --123
select trunc(123.458,0) from dual --123
select trunc(123.458,1) from dual --123.4
select trunc(123.458,-1) from dual --120
select trunc(123.458,-4) from dual --0
select trunc(123.458,4) from dual --123.458
select trunc(123) from dual --123
select trunc(123,1) from dual --123
免责申明:
本文系转载,版权归原作者所有,如若侵权请联系我们进行删除!
《数据治理行业实践白皮书》下载地址:https://fs80.cn/4w2atu
《数栈V6.0产品白皮书》下载地址:https://fs80.cn/cw0iw1
想了解或咨询更多有关袋鼠云大数据产品、行业解决方案、客户案例的朋友,浏览袋鼠云官网:https://www.dtstack.com/?src=bbs
同时,欢迎对大数据开源项目有兴趣的同学加入「袋鼠云开源框架钉钉技术群」,交流最新开源技术信息,群号码:30537511,项目地址:https://github.com/DTStack