码迷,mamicode.com
首页 > 数据库 > 详细

oracle trunc()函数

时间:2017-02-22 13:05:22      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:返回   div   highlight   c函数   nbsp   sys   精确   run   date   

trunc函数

date为必要参数

语法格式TRUNC(date,[fmt])

select sysdate from dual; --当前时间  2016/9/7 10:32:04

select trunc(sysdate) from dual;--取当天  2016/9/7

select trunc(sysdate,‘yyyy‘) from dual; --取当年第一天  2016/1/1

select trunc(sysdate,‘mm‘) from dual; --取当月第一天  2016/9/1

select trunc(sysdate,‘dd‘) from dual; --取当天 2016/9/7

select trunc(sysdate,‘d‘) from dual; --返回当前星期的第一天  2016/9/4

select trunc(sysdate,‘hh‘) from dual; --返回当前时间,精确到小时  2016/9/7 10:00:00

select trunc(sysdate,‘mi‘) from dual; --返回当前时间,精确到分钟 2016/9/7 10:32:00

 trunc(for number)

select trunc(2016.11) from dual; --2016

select trunc(2016.99) from dual; --2016

select trunc(2016.99,1) from dual; --2016.9

select trunc(2016.99,3) from dual; --2016.99

select trunc(2016.99,-1) from dual; --2010

select trunc(2016.99,-2) from dual; --2000

select trunc(2016.99,-4) from dual; --0

select trunc(2016,1) from dual; --2016

select trunc(2016,-1) from dual; --2010

 

oracle trunc()函数

标签:返回   div   highlight   c函数   nbsp   sys   精确   run   date   

原文地址:http://www.cnblogs.com/chengx/p/6428001.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!