then date is truncated to the nearest day. Please refer to "ROUND and TRUNC Date Functions" for the permitted format models to use in fmt. Examples The following example truncates a date: SELECT TRUNC(TO_DATE('27-OCT-92','DD-MON-YY'), 'YEAR') "New Year" FROM DUAL; New Year --...
Oracle 9i, Oracle 10g, Oracle 11g 例如: You could use the decode function in an SQL statement as follows: select supplier_name,decode(supplier_id,1000,'IBM',10001,'Microsoft','1002','Hewlett Packard','Gateway') result from suppliers; 上面的sql语句相当于下面的IF-THEN-ELSE : IF supplier_i...
trunc function 语法如下: trunc( number, [ decimal_places ] ) number 要截取的数字。 decimal_places 要保留的小数位. 这个参数必须是个整数. 如果此参数缺省,默认保留0位小数 应用于:Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g 例如For example: trunc(125.815) would return 125 trunc(125.815, 0) ...
The following example truncates a date: SELECT TRUNC(TO_DATE('27-OCT-92','DD-MON-YY'), 'YEAR') "New Year" FROM DUAL; New Year --- 01-JAN-92 Formatting Dates using TRUNC: Examples In the following example, theTRUNCfunction returns the input date with the time portion of the day ...
应用于: Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g 例如For example: 如果decimal_places大于number本身的小数位数,返回原数字不会加0. 如:trunc(125.81,3) would return 125.81; 如果decimal_places为负数,那么将指定的位数
Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g For example: trunc(125.815) would return 125 trunc(125.815, 0) would return 125 trunc(125.815, 1) would return 125.8 trunc(125.815, 2) would return 125.81 trunc(125.815, 3) would return 125.815 ...
Let's look at some Oracle TRUNC function examples and explore how to use the TRUNC function in Oracle/PLSQL. For example: TRUNC(TO_DATE('22-AUG-03'), 'YEAR') Result: '01-JAN-03' TRUNC(TO_DATE('22-AUG-03'), 'Q') Result: '01-JUL-03' TRUNC(TO_DATE('22-AUG-03'), 'MONTH...
How to truncate date functions in Oracle?The TRUNC (date) function is used to get the date with the time portion of the day truncated to a specific unit of measure, such as day, month, or year. It operates according to the rules of the Gregorian calendar....
RESULT --- 01-APR-20 In this example, we replaced the month (MM) by quarter (Q). In this tutorial, you have learned how to use the OracleTRUNC()function to truncate a date value to a specified unit. Was this tutorial helpful?
Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i Example for dates Let’s consider some examples of theTRUNCfunction and learn how to use the TRUNC function inOracle/PLSQL. SELECT TRUNC(TO_DATE('31.08.2014'), 'YEAR') FROM DUAL; ...