Oracle数字、日期截取函数TRUNC

来源:互联网 发布:电力大数据的几种形式 编辑:程序博客网 时间:2024/05/22 06:20

http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions200.htm

http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions201.htm


trunc_number:


trunc(number)函数返回n1截取到n2位小数。如果省略n2参数,然后n1截取0位小数。n2可以是负数,将从n1小数点向左截取n2位。


这个函数可以采用任何数字数据类型或者任何能够被隐式地转换成数字数据类型的非数字数据类型作为一个参数。如果你省略n2,然后函数返回同这个参数的数字数据类型一样的数据类型。如果你包括n2,然后函数返回number数据类型。



trunc_date:


trunc(date) 函数返回参数date这一天的时间部分截取到由格式化模型fmt参数指定的单位(The TRUNC (date) function returns date with the time portion of the day truncated to the unit specified by the format model fmt)。被返回的值一直是date数据类型,即使你为参数date指定一个不同的datetime数据类型。如果你省略参数fmt,然后参数date被截取到最近的一天。



0 0
原创粉丝点击