0

I have sysdate:

    04-JUN-14

and I need to convert it to datetime:

    i.e.:   2014-06-04T01:00:02
    format: yyyy-mm-ddThh24:mi:ss

is this doable?

Angelina
  • 2,175
  • 10
  • 42
  • 82

1 Answers1

1

There is a little trick because of the T inside your format, so you have to cut it in two:

with w as
(
  select sysdate d from dual
)
select to_char(w.d, 'yyyy-mm-dd') || 'T' || to_char(w.d, 'hh24:mi:ss')
from w;

EDIT : A better way exists in a single call to to_char, as shown in this other SO post:

select to_char(sysdate, 'yyyy-mm-dd"T"hh24:mi:ss') from dual;
Community
  • 1
  • 1
Emmanuel
  • 13,935
  • 12
  • 50
  • 72