oracle函数trunc()⽤法
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 specif
Examples
The following example truncates a date:
SELECT TRUNC(TO_DATE('27-OCT-92','DD-MON-YY'), 'YEAR')
"New Year" FROM DUAL;
hue trunc函数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;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论