Is there any equivalent stuff function in oracle? I used the stuff function in mssql to convert the raw datetime ( in string format) to proper datetime MSSQL Query
select convert(datetime,
'20'+substring(stuff(stuff(stuff(stuff(stuff(stuff(convert(varchar,'24051103084950') , 3,0,'-'), 6,0,'-'), 9,0,' '), 12,0,':'), 15,0,':'), 17,2,''),7,2)+'-'
+SUBSTRING(stuff(stuff(stuff(stuff(stuff(stuff(convert(varchar,'24051103084950'),3,0,'-'), 6,0,'-'), 9,0,' '), 12,0,':'), 15,0,':'), 17,2,''),4,2)+'-'
+SUBSTRING (stuff(stuff(stuff(stuff(stuff(stuff(convert(varchar,'24051103084950'), 3,0,'-'), 6,0,'-'), 9,0,' '), 12,0,':'), 15,0,':'), 17,2,''),1,2)
+ SUBSTRING(stuff(stuff(stuff(stuff(stuff(stuff( convert(varchar,'24051103084950'),3,0,'-'), 6,0,'-'), 9,0,' '), 12,0,':'), 15,0,':'), 17,2,''),9,15))
In the above query '24051103084950' is the raw data which is in ddmmyyhhmiss format. The output for the above query is as follows
(No column name)
2011-05-24 03:08:40.000
I need to convert the same query into oracle. Guide me to do it.
You could use the timestamp/string conversion functions to simplify this:
select to_char(
to_timestamp('24051103084950', 'DDMMYYHH24MISSFF2'),
'YYYY-MM-DD HH24:MI:SS.FF3')
from dual
N.B. FF2 is milliseconds to 2 places, FF3 is milliseconds to 3 places.