Angelina
Angelina

Reputation: 2265

converting sysdate to datetime format

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?

Upvotes: 0

Views: 1301

Answers (1)

Emmanuel
Emmanuel

Reputation: 14209

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;

Upvotes: 1

Related Questions