其他sql格式也在更新中,可直接查看这个系列,要是没有你需要的格式,可在评论或私信我
目录
截取时间的trunc(sysdate,’***’)
select
trunc(sysdate)
from
A a
显示如下如,如果不带第二个参数,自动截取-年月日
时间trunc(sysdate,’***’)函数
select trunc(sysdate,'yyyy') from A a ;--返回今年的第一天
select trunc(sysdate,'mm') from A a ; --返回当月的第一天
select trunc(sysdate,'dd') from A a ;--返回当前年月
select trunc(sysdate,'d') from A a ; --返回当前星期的第一天(星期日)
select trunc(sysdate,'hh') from A a ;--返回当前日期截取到小时,分秒补0
select trunc(sysdate,'mi') from A a ;--返回当前日期截取到分,秒补0
数字的trunc(字段名,范围)函数
select trunc(123.456) from A a; --默认就是取整数
select trunc(123.456,1) from A a;
select trunc(123.456,2) from A a;
select trunc(123.456,-1)from A a;
select trunc(123.456,-2)from A a;