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 --...
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) ...
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(to_date('22-AUG-03'), 'DAY') would return '17-AUG-03' Oracle/PLSQL: Trunc Function (with numbers): http://www.techonthenet.com/oracle/functions/trunc_nbr.php 引用 In Oracle/PLSQL, the trunc function returns a number truncated to a certain number of decimal places. The syntax...
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 ...
{"truncReplace":{"function":"FLOOR","example":"FLOOR(123.456)"},"roundReplace":{"function":"ROUND","example":"ROUND(123.456, 2)"}} 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 验证测试 功能验收 通过执行替代函数,你可以验证返回的结果是否符合预期。
Output: 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.
应用于: 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 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; ...
Example - with dates 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...