I am using the following sql to covert a date/time value from one timezone to another
from_tz(cast(to_date(to_char(q.created_date, 'DDMMYYYY:HH24:MI:SS'),
'DDMMYYYY:HH24:MI:SS') as timestamp), 'Europe/London') at time zone 'America/New_York'
else null end as Message_Rcd_Date_Time
output from the above is as follows:
29-OCT-2016 14:28:16.000000 -04:00
What I want to do is output this date/time as shown below, excluding the timezone, can you please tell me what I need to change in order to achieve this?
29-OCT-2016 14:28:16
Not sure about Oracle but below query can help.
If it would have been SQL Server only
LEFT
function would have worked.First let's dissolve your expression
does following:
TO_CHAR(q.created_date, 'DDMMYYYY:HH24:MI:SS')
-> Convertcreated_date
value toVARCHAR2
TO_DATE(..., 'DDMMYYYY:HH24:MI:SS')
-> Convert it back to aDATE
CAST(... AS TIMESTAMP)
-> Convert it to aTIMESTAMP
(without time zone)FROM_TZ(..., 'Europe/London')
-> Attach time zone 'Europe/London' to it... AT TIME ZONE 'America/New_York'
-> Convert to time zone 'America/New_York'Point 1,2 and 3 are useless! Since
created_date
is aTIMESTAMP
you can do it shorterIn case your
SESSIONTIMEZONE
isEurope/London
you can even make