TO_DSINTERVAL

TO_DSINTERVAL is a function in SQL that converts a character string of a specific format into an interval day to second type. It enables SQL queries to manipulate data by specific intervals of days, hours, minutes, and seconds.

TO_DSINTERVAL(string)

  • string: This parameter is a varchar2 datatype that represents the interval to be converted. The format for the string is ‘DY day HH

Example

SELECT SYSTIMESTAMP + TO_DSINTERVAL('0 01:00:00.000') AS New_Timestamp
FROM dual;

Output

NEW_TIMESTAMP
--------------------------------------------------------------------------------
08-MAR-22 03.50.45.123000 PM +00:00

Explanation

The TO_DSINTERVAL function has been used to add 1 hour to the current system timestamp in this case. The string ‘0 01:00:00.000’ in the TO_DSINTERVAL function indicates ‘0 days, 1 hour, 0 minutes and 0 seconds’. The resultant timestamp is displayed under New_Timestamp.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.