I'm working on Amazon Redshift database and I have dates in milliseconds since epoch. I want to convert that to timestamp, and writing this query that I found on another thread
SELECT TIMESTAMP 'epoch' + column_with_time_in_ms/1000 *INTERVAL '1 second'
FROM table_name LIMIT 1000;
gives me the result in YYYY-MM-DD HH:MM:SS.
My question is: How do I write a SQL function in Redshift that takes integer parameter that are the milliseconds and does this conversion?
Thanks.