Choose date + time + time zone with oracle db

I would like to get a date with the following format:

2009-01-15T09: 13: 51.0Z

I use the following statement:

SELECT to_char(sysdate, 'YYYY-mm-DD HH24:MI:SS.') 

But this returns:

2012-11-07 16:12:00.

How can I declare T in the middle and 0Z at the end?

Is this possible, or do I need to use concatenation?

+4
source share
2 answers

put it in double quotes.

 to_char(sysdate, 'YYYY-mm-DD"T"HH24:MI:SS."0Z"') 
+5
source

to_char ((sysdate, '' YYYY-mm-DD HH24: MI: SS TZD ') returns the abbreviated time zone on the user's computer. If in another time zone you need to add / subtract the clock from your own time zone to get the correct time in the current time zone. There is an oracle format with time zone data. Instead of making the column a date, you can make it one of the following sql types

 Type TIMESTAMP adds miliseconds but no timezone. Type TIMESTAMP WITH TIMEZONE same as timestamp but with timezone it was saved with. Type TIMESTAMP WITH LOCAL TIMEZONE same as timestamp but all is saved in local timezone. 
0
source

Source: https://habr.com/ru/post/1444601/


All Articles