Trunc Function (with dates)In Oracle/PLSQL, the trunc function returns a date truncated to a specific unit of measure.oracle中,trunc函数返回一个按照特定计量单位截取后的date值 The syntax for the trunc function is:语法如下:trunc ( dat1e, [ format ] )da1te is the date to tru...
search 和 result可成对出现多次,代表各种要匹配的情况。 应用于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...
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 ...
Examples 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 日期 -- 2020-01-01selecttrunc(TO_DATE('2020-11-08','YYYY-MM-DD'),'YYYY')fromdual; 数字 -- 默认精度为0,结果为123selectt...
Example (with numbers) Let's look at some Oracle TRUNC function examples and explore how to use the TRUNC function in Oracle/PLSQL. For example: TRUNC(125.815)Result:125 TRUNC(125.815, 0)Result:125 TRUNC(125.815, 1)Result:125.8 TRUNC(125.815, 2)Result:125.81 TRUNC(125.815, 3)Result:125.815...
应用于: 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: 如果decimal_places大于number本身的小数位数,返回原数字不会加0. 如:trunc(125.81,3) would return 125.81; 如果decimal_places为负数,那么将指定的位数
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...
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 trunc函数的用法oracle trunc 函数的用法1.TRUNC(for dates)TRUNC 函数为指定元素而截去的日期值。 其具体的语法格式如下: TRUNC(date[,fmt]) 其中: date 一个日期值 fmt 日期格式,该日期将由指定的元素格式所截去。忽略 它则由最近的日期截去 下面是该函数的使用情况: TRUNC(TO_DATE('24-Nov-1999 ...