标签:-- 123.456 用法 date dual oracle select trunc
trunc() 截取日期或者数字
参考链接:https://www.cnblogs.com/xiaoyudz/archive/2011/03/18/1988467.html
官方注释:
Syntax
TRUNC(date [, fmt ])
Purpose
The TRUNC (date) function returns date with the time portion of the day truncated to the unit specified by the format model fmt. The value returned is always of datatype DATE, even if you specify a different datetime datatype for date. If you omit fmt, then date is truncated to the nearest day. Please refer to "ROUND and TRUNC Date Functions" for the permitted format models to use in fmt.
Examples
The following example truncates a date:
SELECT TRUNC(TO_DATE('27-OCT-92','DD-MON-YY'), 'YEAR')
"New Year" FROM DUAL;
New Year
---------
01-JAN-92
日期
-- 2020-01-01
select trunc(TO_DATE('2020-11-08', 'YYYY-MM-DD'),'YYYY') from dual;
数字
-- 默认精度为0,结果为123
select trunc(123.456) from dual;
-- 123.45 采用的是去尾法
select trunc(123.456, 2) from dual;
-- 120
select trunc(123.456, -1) from dual;;
-- 100
select trunc(123.456, -2) from dual;
-- 0
select trunc(123.456, -3) from dual;
标签:--,123.456,用法,date,dual,oracle,select,trunc 来源: https://www.cnblogs.com/BearBird/p/15823307.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。