I'm dealing with two redshift tables where each one have different formats of time stamps.
table 1 - start_date: 2013-07-26 07:30:17.0
table 2 - end_date: 20140517004819823Z
My requirement is to have both in the same format (like table 1, start date) so that i can use datediff to find the interval between them.
How do i format the table 2 end date similar to table 1. I've tried
cast(end_date as timestamp) but it throws Invalid data code: 8001
Edit 1:
Tried Using to_timestamp(end_date, 'YYYY-MM-DD HH24:MI:SS', false) but it throws Invalid operation: value for "YYYY" in source string is out of range;
"YYYY" in source string is out of range". Any idea how to fix this - Adam SmithYYYY-MM-DD HH24:MI:SS-- it looks more likeYYYYMMDDHHMMSSand some other bits on the end. You will need to tell Redshift how the string is formatted so that it can convert it to a timestamp. Please read the linked documentation. - John Rotensteinto_timestamp(end_date, 'YYYYMMDDHH24MISS', false)and20150425201043668Zis getting returned as2015-04-26 08:17:48.0. Not sure if the timestamp is correct though. - Adam Smith