博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TRUNC 截取日期或数字,返回指定的值。
阅读量:7103 次
发布时间:2019-06-28

本文共 1297 字,大约阅读时间需要 4 分钟。

TRUNC(
number,num_digits)
Number 需要截尾取整的数字。
Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。
 
/**************日期********************/ 1.select trunc(sysdate) from dual  --2011-3-18  今天的日期为2011-3-18 2.select trunc(sysdate, 'mm')   from   dual  --2011-3-1    返回当月第一天. 3.select trunc(sysdate,'yy') from dual  --2011-1-1       返回当年第一天 4.select trunc(sysdate,'dd') from dual  --2011-3-18    返回当前年月日 5.select trunc(sysdate,'yyyy') from dual  --2011-1-1   返回当年第一天 6.select trunc(sysdate,'d') from dual  --2011-3-13 (星期天)返回当前星期的第一天 7.select trunc(sysdate, 'hh') from dual   --2011-3-18 14:00:00   当前时间为14:41   8.select trunc(sysdate, 'mi') from dual  --2011-3-18 14:41:00   当前分钟 TRUNC()函数没有秒的精确 /***************数字********************/ /* TRUNC(number,num_digits) Number 需要截尾取整的数字。 Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。 TRUNC()函数截取时不进行四舍五入 */ 9.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

查询某天的数据?

select * from table_name where trunc(日期字段)=to_date('2003-05-02','yyyy-mm-dd');

转载地址:http://gdchl.baihongyu.com/

你可能感兴趣的文章
Ubuntu安装 和 python开发
查看>>
「洛谷P3931」 SAC E#1 - 一道难题 Tree
查看>>
C#压缩库SharpZipLib的应用
查看>>
C# Type
查看>>
我的博客地址和github地址
查看>>
最大公约数(gcd)还有最小公倍数(lcm)的共通之处
查看>>
2018.10.30-dtoj-4009-秀秀的森林(forest)
查看>>
[LeetCode] Strobogrammatic Number II
查看>>
《C语言》-(static和extern)
查看>>
HBase Snapshot简介
查看>>
//……关于TCP三次握手与四次挥手
查看>>
blocksit
查看>>
renderscript 浅析(一)
查看>>
弹出对话框---MessageBox
查看>>
定义的命令不可用的原因及解决办法
查看>>
libevent(十三)evhttp事件处理流程
查看>>
1004. 西西弗斯式的命运——java
查看>>
jquery弹出遮掩层
查看>>
前端基础-CSS
查看>>
14、BigInteger类简介
查看>>