获得当前季度
复制代码
1
2select trunc((to_char(sysdate,'mm')+2)/3) from dual;
获得当前月份
复制代码
1
2select to_char(sysdate,'mm') from dual;
逻辑:
复制代码
1
2
3
4
5
6
7
8获得当前时间对应的季度逻辑: (当前月份+2)/3 12月份是第四季度 select trunc(12+2/3) from dual; 返回结果: 4 6月份是第二季度 select trunc(6+2/3) from dual; 返回结果: 2
trunc() 函数对于日期: 按照指定格式返回日期
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
161.select trunc(sysdate) from dual --2020-3-18 今天的日期为2020-3-18 2.select trunc(sysdate, 'mm') from dual --2020-3-1 返回当月第一天. 3.select trunc(sysdate,'yy') from dual --2020-1-1 返回当年第一天 4.select trunc(sysdate,'dd') from dual --2020-3-18 返回当前年月日 5.select trunc(sysdate,'yyyy') from dual --2020-1-1 返回当年第一天 6.select trunc(sysdate,'d') from dual --2020-3-13 (星期天)返回当前星期的第一天 7.select trunc(sysdate, 'hh') from dual --2020-3-18 14:00:00 当前时间为14:41 8.select trunc(sysdate, 'mi') from dual --2020-3-18 14:41:00 trunc()函数没有秒的精确
trunc() 函数对于数字: 按照指定精度截取数据,小数点右边直接截取,小数点左边置为0, 截取时不进行四舍五入;
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
199.select trunc(123.458) from dual --123 10.select trunc(123.458,0) from dual --123 11.select trunc(123.458,1) from dual --123.4 12.select trunc(123.458,-1) from dual --120 13.select trunc(123.458,-4) from dual --0 14.select trunc(123.458,4) from dual --123.458 15.select trunc(123) from dual --123 16.select trunc(123,1) from dual --123 17.select trunc(123,-1) from dual --120
最后
以上就是时尚糖豆最近收集整理的关于Oracle 获取当前季度的全部内容,更多相关Oracle内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复