|
Re: Need Date format in YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) [message #665800 is a reply to message #665799] |
Wed, 20 September 2017 18:00 |
Solomon Yakobson
Messages: 3275 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
SYSDATE returns DATE and Oracle DATEs do not store time zone information. Use SYSTEMISTAMP instead - it returns TIMESTAMP WITH TIME ZONE. Also T is not a valid format element and should be enclosed in double quotes. Format element for fractional part of a second is ff, so it should be ss.ff, not as ss.s. Format element hh implies 12 hour clock and should be used together with AM or PM - I'll use 24 hour clock. To display himezone in hours and minutes use txh:tzm. And in general, RTFM - all this is clearly documented:
SQL> select to_char(systimestamp,'YYYY-MM-DD"T"hh24:mi:ss.ffTZH:TZM')
2 from dual
3 /
TO_CHAR(SYSTIMESTAMP,'YYYY-MM-DD"T"
-----------------------------------
2017-09-20T18:59:25.040000-04:00
SQL>
SY.
[Updated on: Wed, 20 September 2017 18:12] Report message to a moderator
|
|
|
|
|