Oracle trunc()函数的用法
来源:互联网 发布:自学网站美工 编辑:程序博客网 时间:2024/06/09 20:31
--Oracle trunc()函数的用法
/**************日期********************/
1.select trunc(sysdate) from dual --2013-01-06 今天的日期为2013-01-06
2.select trunc(sysdate, 'mm') from dual --2013-01-01 返回当月第一天.
3.select trunc(sysdate,'yy') from dual --2013-01-01 返回当年第一天
4.select trunc(sysdate,'dd') from dual --2013-01-06 返回当前年月日
5.select trunc(sysdate,'yyyy') from dual --2013-01-01 返回当年第一天
6.select trunc(sysdate,'d') from dual --2013-01-06 (星期天)返回当前星期的第一天
7.select trunc(sysdate, 'hh') from dual --2013-01-06 17:00:00 当前时间为17:35
8.select trunc(sysdate, 'mi') from dual --2013-01-06 17:35:00 TRUNC()函数没有秒的精确
/***************数字********************/
/*
TRUNC(number,num_digits)
Number 需要截尾取整的数字。
Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。
TRUNC()函数截取时不进行四舍五入
*/
9.select trunc(123.458) from dual --123
10.select trunc(123.458,0) from dual --123
11.select trunc(123.458,1) from dual --123.4
12.select trunc(123.458,-1) from dual --120
13.select trunc(123.458,-4) from dual --0
14.select trunc(123.458,4) from dual --123.458
15.select trunc(123) from dual --123
16.select trunc(123,1) from dual --123
4
ROUND——按照指定的精度进行四舍五入
SQL> select round(3.1415926,4) from dual;
ROUND(3.1415926,4)
------------------
3.1416
TRUNC——按照指定的精度进行截取一个数
SQL> select trunc(3.1415926,4) from dual;
ROUND(3.1415926,4)
------------------
3.1415
/**************日期********************/
1.select trunc(sysdate) from dual --2013-01-06 今天的日期为2013-01-06
2.select trunc(sysdate, 'mm') from dual --2013-01-01 返回当月第一天.
3.select trunc(sysdate,'yy') from dual --2013-01-01 返回当年第一天
4.select trunc(sysdate,'dd') from dual --2013-01-06 返回当前年月日
5.select trunc(sysdate,'yyyy') from dual --2013-01-01 返回当年第一天
6.select trunc(sysdate,'d') from dual --2013-01-06 (星期天)返回当前星期的第一天
7.select trunc(sysdate, 'hh') from dual --2013-01-06 17:00:00 当前时间为17:35
8.select trunc(sysdate, 'mi') from dual --2013-01-06 17:35:00 TRUNC()函数没有秒的精确
/***************数字********************/
/*
TRUNC(number,num_digits)
Number 需要截尾取整的数字。
Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。
TRUNC()函数截取时不进行四舍五入
*/
9.select trunc(123.458) from dual --123
10.select trunc(123.458,0) from dual --123
11.select trunc(123.458,1) from dual --123.4
12.select trunc(123.458,-1) from dual --120
13.select trunc(123.458,-4) from dual --0
14.select trunc(123.458,4) from dual --123.458
15.select trunc(123) from dual --123
16.select trunc(123,1) from dual --123
17.select trunc(123,-1) from dual --120
FLOOR——对给定的数字取整数位
SQL> select floor(2345.67) from dual;
FLOOR(2345.67)
--------------
2345
CEIL--返回大于或等于给出数字的最小整数
SQL> select ceil(3.1415927) from dual;
CEIL(3.1415927)
---------------
ROUND——按照指定的精度进行四舍五入
SQL> select round(3.1415926,4) from dual;
ROUND(3.1415926,4)
------------------
TRUNC——按照指定的精度进行截取一个数
SQL> select trunc(3.1415926,4) from dual;
ROUND(3.1415926,4)
------------------
0 0
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- Oracle trunc()函数的用法
- Oracle trunc()函数的用法
- oracle trunc()函数的用法
- oracle trunc()函数的用法
- Oracle trunc()函数的用法
- Oracle trunc()函数的用法
- oracle trunc()函数的用法
- Oracle trunc()函数的用法
- Oracle trunc()函数的用法
- Oracle trunc()函数的用法
- Oracle trunc()函数的用法
- JS解析json数据(怎么把json字符串转化为数组)
- Android——Handler内存泄露
- oracle 非分区表转分区表
- USB鼠标设备驱动程序简单实现(二)
- 【javaScript】报getElementId()为Null的错误
- Oracle trunc()函数的用法
- 计算机书籍汇总
- 在云服务器上从零搭建nginx+uwsgi+django服务器
- spring mvc 返回json乱码
- C语言中#define使用方法
- api文档工具-将json对象转行表
- 归并排序之数组和链表
- 微信小程序开发常见问题FAQ之七
- calcHist的使用中严重的错误和误区!!!!!!!为什么所有的文章都没有指出??