Reputation: 45
I have recieved a particular date in the particular format 2015-06-13T21:49:13.395-07:00 which is inserted as varchar in database.
I want to convert this date into DATE format but am not getting the right formatter for the same
Upvotes: 0
Views: 154
Reputation: 11
SELECT CAST(LEFT(REPLACE('2015-06-13T21:49:13.395-07:00','T',' '),23) AS DATETIME)
Upvotes: 0
Reputation: 27251
Use to_timestamp_tz()
function to convert your string to a value of timestamp with timezone data type:
select to_timestamp_tz('2015-06-13T21:49:13.395-07:00'
, 'yyyy-mm-dd"T"hh24:mi:ss.ffTZH:TZM') as res
from dual
Result:
RES
----------------------------------
13.06.15 21:49:13,395000000 -07:00
Upvotes: 5