Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 481
milheiros Avatar asked Dec 30 '25 21:12

milheiros


1 Answers

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;
like image 97
Kacper Avatar answered Jan 01 '26 11:01

Kacper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!