Convert Gregorian Date to timestamp in Oracle


I am trying to convert a Gregorian date format to regular timestamp in Oracle SQL. Also, I need that time to account for Daylight savings time. Here is syntax I used but using NEW_TIME cuts the milleseconds from the timestamp. How can I account for millesonds and still do the DST. Please assist. Thank you

Actual Column (Assign Time) : 2015-05-27T17:07:12.065Z
Expected Result: 5/27/2015 12:07:12.065000000 PM
Received outcome using New_time: 5/27/2015 12:07:12 PM

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you want to get 12:07 pm  as a timestamp

FROM_TZ(TO_TIMESTAMP(z."PXASSIGNDATETIME", 'yyyy-mm-dd"T"hh24:mi:ss.FF"Z"'), 'GMT') AT TIME ZONE '-05:00'

but...  EDT (assuming you mean US/Eastern DST) would actually be 13:07, not 12:07  because EDT has a 4 hour offset, not 5.

easiest way to handle that is to use the full tz name:

FROM_TZ(TO_TIMESTAMP(z."PXASSIGNDATETIME", 'yyyy-mm-dd"T"hh24:mi:ss.FF"Z"'), 'GMT') AT TIME ZONE 'US/Eastern'

both of these return timestamp with time zone types
so,in  either case , to get the formatting you want,  wrap the whole thing in to_char

to_char(FROM_TZ(TO_TIMESTAMP(z."PXASSIGNDATETIME", 'yyyy-mm-dd"T"hh24:mi:ss.FF"Z"'), 'GMT') at time zone 'US/Eastern','fmmm/dd/yyyy hh24:mi:ss.ff9 am')

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
angel7170Author Commented:
Awesome, it works! I used

FROM_TZ(TO_TIMESTAMP(z."PXASSIGNDATETIME", 'yyyy-mm-dd"T"hh24:mi:ss.FF"Z"'), 'GMT') AT TIME ZONE 'US/Eastern'

Thank you very much
glad I could help.

the reason NEW_TIME didn't work is NEW_TIME only works on dates, not timestamps.

So, when you passed in a timestamp, it converted it implicitly to a date and then returned a date, hence the missing milliseconds.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.