Oracle TRUNC(date) & TRUNC(number)

TRUNC(number[,decimals])

number 待做截取处理的数值
decimals 指明需保留小数点后面的位数。可选项,忽略它则截去所有的小数部分(默认为0)

select TRUNC(5.75) from dual;
--Output:5

select TRUNC(-5.75) from dual;
--Output:-5

SELECT TRUNC(109.29, 1) truncated  FROM dual;
--Output:109.2

SELECT TRUNC(109.29, -1) truncated  FROM dual;
--Output:100

SELECT TRUNC(1234.5678, -3) FROM DUAL;
--Output:1000

TRUNC(date[,fmt])

date 一个日期值

fmt 日期格式,该日期将由指定的元素格式所截去。忽略它则由最近的日期截去

SELECT SYSDATE FROM dual;
--Output:04.06.2012 22:37:03

SELECT trunc(sysdate,'yyyy') FROM dual;
--Output:01.01.2012 00:00:00,返回当年第一天.

SELECT trunc(sysdate,'mm') FROM dual;
--Output:01.06.2012 00:00:00 返回当月第一天.

SELECT trunc(sysdate,'d') FROM dual;
--Output:03.06.2012 00:00:00 返回当前星期的第一天.

SELECT trunc(sysdate,'dd') FROM dual;
--Output:04.06.2012 00:00:00 返回当前年月日

select trunc(sysdate) FROM dual;
--Output:04.06.2012 00:00:00

select * from MTL_MATERIAL_TRANSACTIONS 
where trunc(creation_date) = To_Date('04-06-2012','dd-mm-yyyy');

转载请注明出处: http://blog.csdn.net/pan_tian/article/details/7634095

你可能感兴趣的:(oracle,Date,transactions)