Convert string to an interval Day to Second type in oracle using TO_DSINTERVAL function

By Santhosh N

This explains how to convert the string to an interval Day to Second type in oracle.

There is a conversion function in oracle by the name, TO_DSINTERVAL which converts the specified string to an interval Day to Second type in oracle.

Syntax: TO_DSINTERVAL(char, [nls])

Here char is the value of the string that needs to be converted and it can be a char, varchar2, nchar or nvarchar2 type. nls is the decimal and group separator characters which are optional. In order to specify this you need to use this as NLS_NUMERIC_CHARACTERS = “dg” where d is the decimal character and g is the group seperator character.

Ex1: SELECT TO_DSINTERVAL('1012 12:12:12') FROM dual;
This returns “+1012 12:12:12.000000” as result

Ex2: SELECT TO_DSINTERVAL('103 10:12:12') FROM dual;
This returns “+103 10:12:12.000000” as result

Ex3: SELECT TO_DSINTERVAL('1012 12:12:12','NLS_NUMERIC_CHARACTERS = ".,"') FROM dual;
This returns “+1012 12:12:12.000000” as result

Related FAQs

This explains how to convert the given number to the interval year to the month literal in oracle
Use Oracle TO_NUMBER to convert a string to a number and format the number in the desired nls language.
This explains how to convert the given number to the interval (which can be days, hours, minutes, or seconds) in the oracle using the NUMTODSINTERVAL conversion function
This explains how to convert the bit vector to a number in the oracle using the BIN_TO_NUM conversion function.
This explains how to convert the the given date or integer values to strings.
This explains how to convert the string to date format in oracle.
Convert string to an interval Day to Second type in oracle using TO_DSINTERVAL function  (2467 Views)