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 (12.34) from dual--12
  select trunc (12.34789) from dual--12
  select trunc (12.34789,2) from dual--12.34
  select trunc (12.34489,2) from dual--12.34
  select trunc (12.34489,-1) from dual--10
  select trunc (15.34489,-1) from dual--10
  select trunc (15.34489,-2) from dual--0

posted @ 2018-05-11 13:52  wupf  阅读(307)  评论(0编辑  收藏  举报