trunc函数 oracle

1,【trunc(for dates)】TRUNC()函数处理日期
select trunc(sysdate,'yy') from dual;--返回当年第一天
select trunc(sysdate,'mm') from dual;--返回当月的第一天
select trunc(sysdate,'dd') from dual;--返回当前日期
2,【TRUNC(for number)】TRUNC()函数处理number型数字
select trunc(123.567,2) from dual;--123.56,将小数点右边指定位数后面的截去;
select trunc(123.567,-2) from dual;--100,第二个参数可以为负数,表示将小数点左边指定位数后面的部分截去,即均以0记;
select trunc(123.567) from dual;--123,默认截去小数点后面的部分;

猜你喜欢

转载自www.cnblogs.com/wupf/p/9024214.html
今日推荐