oracle 函数 TO_DSINTERVAL 日期随意加减

在学习oracle自带的帮助文件过程发现一个日期加减的好函数,可以对日期随意加减

如下例了,对原来的时间加一天

参数格式为 天数 时,分,秒

 

select create_time,TO_DSINTERVAL('01 00:00:00')+create _time as dd from a

id        create_time                     dd

1 2012-03-09 10:46:19 2012-03-10 10:46:19
2 2012-03-09 13:54:28 2012-03-10 13:54:28
3 2012-03-09 13:54:43 2012-03-10 13:54:43
4 2012-03-14 16:32:58 2012-03-15 16:32:58
5 2012-03-14 16:35:08 2012-03-15 16:35:08
6 2012-03-15 12:53:46 2012-03-16 12:53:46
7 2012-03-15 12:53:46 2012-03-16 12:53:46
8 2012-03-15 12:53:46 2012-03-16 12:53:46
9 2012-03-15 13:30:13 2012-03-16 13:30:13
10 2012-03-15 13:30:13 2012-03-16 13:30:13
11 2012-03-15 13:30:13 2012-03-16 13:30:13
12 2012-03-15 17:58:31 2012-03-16 17:58:31

以下是原有译文:

TO_DSINTERVAL converts a character string of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype to an INTERVAL DAY TO SECOND type.

TO_DSINTERVAL accepts argument in one of the two formats:

  • SQL interval format compatible with the SQL standard (ISO/IEC 9075:2003)

  • ISO duration format compatible with the ISO 8601:2004 standard

In the SQL format, days is an integer between 0 and 999999999, hours is an integer between 0 and 23, and minutes and seconds are integers between 0 and 59. frac_secs is the fractional part of seconds between .0 and .999999999. One or more blanks separate days from hours. Additional blanks are allowed between format elements.

In the ISO format, days, hours, minutes and seconds are integers between 0 and 999999999. frac_secs is the fractional part of seconds between .0 and .999999999. No blanks are allowed in the value.

你可能感兴趣的:(TO_DSINTERVAL)