Oracle中trunc()函数的用法
来源:互联网 发布:英国为什么要脱欧 知乎 编辑:程序博客网 时间:2024/05/14 14:39
(1)处理日期:TRUNC函数为指定元素而截去的日期值
格式:trunc(date,[format])
select trunc(sysdate) from dual; --2013-12-15 返回当前日期select trunc(sysdate, 'mm') from dual; --2013-12-1 返回当月第一天.select trunc(sysdate,'yy') from dual; --2013-1-1 返回当年第一天select trunc(sysdate,'dd') from dual; --2013-12-15 返回当前年月日select trunc(sysdate,'yyyy') from dual; --2013-12-15 返回当年第一天select trunc(sysdate, 'hh') from dual; --2013-12-15 20:00:00 当前时间为20:41 select trunc(sysdate, 'mi') from dual; --2013-12-15 20:41:00 TRUNC()函数没有秒的精确
即:当format为年时,精确到年;当format为月时,精确到年,月;当format为日时,精确到年,月,日;
(2)trunc(n,[m]):用于截取,若省略m,就截去小数部分,如果m是正数,就截取到小数点的m位后,如果m是负数,就截取到小数点的前m位;
select trunc(123) from dual --123select trunc(123.458) from dual --123select trunc(123.458,0) from dual --123select trunc(123.458,1) from dual --123.4select trunc(123.458,2) from dual --123.45select trunc(123.458,4) from dual --123.458
select trunc(123.458,-1) from dual --120select trunc(123.458,-2) from dual --100select trunc(123.458,-4) from dual --0select trunc(123,1) from dual --123select trunc(123,-1) from dual --120
0 0
- oracle中trunc函数的用法
- oracle中trunc函数的用法
- Oracle中trunc()函数的用法
- ORACLE中TRUNC函数的用法
- Oracle中trunc()函数的用法!
- Oracle中TRUNC() 函数用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- Oracle trunc()函数的用法
- Oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- Oracle trunc()函数的用法
- 多线程经典问题-----乘客做公交车问题解答3
- 跳槽前的总结
- 设计笔记
- Codeforces Round #219 (Div. 2) E. Watching Fireworks is Fun
- 查看某个字段在哪些表出现过
- Oracle中trunc()函数的用法
- python编译
- Gist描述子
- 开题报告、文献检索账号、文献综述、外文翻译、抄袭检测软件、论文目录,都在这了都在这了,有备无患,拿去吧!
- 参与英雄会第一届在线编程大赛:单词博弈
- 烦请大家支持一票,谢谢!!
- 打开word,出现“当前用户没有安装Microsoft office word.请运行安装程序安装该应用程序。”提示
- 小学徒博客索引
- 软件工程---软件需求分析