The TO_DSINTERVAL function converts a string of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type to a value of the INTERVAL DAY TO SECOND data type. You can add and subtract a date and time value by using this function.
Syntax
TO_DSINTERVAL(days hours:minutes:seconds[.frac_secs])
Parameters
| Parameter | Description |
|---|---|
| days hours:minutes:seconds[.frac_secs] | A string of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type in the format specified by this parameter. |
Return type
INTERVAL DAY TO SECOND data type
Examples
The following example returns the date and time value that is 100 days after the current time:
SELECT SYSDATE, SYSDATE+TO_DSINTERVAL('100 00:00:00') FROM DUAL;
The following query result is returned:
+---------------------+--------------------------------------+
| SYSDATE | SYSDATE+TO_DSINTERVAL('10000:00:00') |
+---------------------+--------------------------------------+
| 2020-03-26 12:40:39 | 2020-07-04 12:40:39 |
+---------------------+--------------------------------------+