milheiros milheiros - 5 days ago 7
SQL Question

Timezone date format in Oracle

I have to convert a

SYSDATE
date to a specific date format. That format must be something like this:
'2016-11-23T15:12:48Z'
. I think this is a weird date format but is the requirements that I have.

This must be a date to send in a Web Service message.

In Oracle (12c or 11g) I have some function to transform a date in this specific format? Thanks.

Answer

That will give you ISO-8601 mentioned in comment:

select to_char(systimestamp,'YYYY-MM-DD"T"hh24:mi:sstzh:tzm') isodt from dual;

If you really want Z instead of timezone you can use:

    select to_char(cast(systimestamp as timestamp) at time zone 'UTC',
               'yyyy-mm-dd"T"hh24:mi:ss"Z"')
    from dual;
Comments