Home » SQL & PL/SQL » SQL & PL/SQL » Date format with UTC
Date format with UTC [message #681128] Thu, 18 June 2020 03:35 Go to next message
Mark70
Messages: 17
Registered: June 2020
Junior Member
Hi,
I have to select the value 2019-03-25 from a date column of a table but in the following format:
2019-03-25T00:00:00.000+02:00
Hon can I get it?

Oracle 10g

Thanks!

[Updated on: Thu, 18 June 2020 03:53]

Report message to a moderator

Re: Date format with UTC [message #681129 is a reply to message #681128] Thu, 18 June 2020 04:00 Go to previous messageGo to next message
John Watson
Messages: 8426
Registered: January 2010
Location: Global Village
Senior Member
You need to use appropriate format elements, for example,
R19 orclz> select to_char(systimestamp,'yyyy-mm-dd hh24:mi:ssTZH:TZM') from dual;

TO_CHAR(SYSTIMESTAMP,'YYY
-------------------------
2020-06-18 09:58:31+01:00

R19 orclz>
Re: Date format with UTC [message #681132 is a reply to message #681129] Thu, 18 June 2020 06:45 Go to previous messageGo to next message
EdStevens
Messages: 1282
Registered: September 2013
Senior Member
Also asked on SO - https://stackoverflow.com/questions/62446017/date-format-with-utc
Re: Date format with UTC [message #681170 is a reply to message #681132] Mon, 22 June 2020 07:18 Go to previous messageGo to next message
Bill B
Messages: 1969
Registered: December 2004
Senior Member
If the table column is of type DATE and not TIMESTAMP you would do the following where you would replace the function SYSDATE with the name of the column

select to_char(cast(sysdate AS TIMESTAMP WITH TIME ZONE),'yyyy-mm-dd hh24:mi:ssTZH:TZM') from dual;

2020-06-22 08:17:27-04:00

[Updated on: Mon, 22 June 2020 07:21]

Report message to a moderator

Re: Date format with UTC [message #682009 is a reply to message #681170] Fri, 25 September 2020 03:44 Go to previous message
Mark70
Messages: 17
Registered: June 2020
Junior Member
Thank you to everyone!
Previous Topic: How to use table functions
Next Topic: Can't connect with new user created
Goto Forum:
  


Current Time: Thu Nov 26 15:46:05 CST 2020