Skip to content
Advertisement

Redshift – Error when converting UTC time to local time in where clause

I have some sales data that is recorded in UTC. I am trying to convert it to the local timezone where the sales happened.

I have built up a query as below but get an error saying invalid operation: function to_char(timestamp without time zone, charcter varying, unknown”) does not exist.

Could anyone advice how I could modify this query. I am using redshift DB. Thanks.

Advertisement

Answer

I would suggest to use ‘CONVERT_TIMEZONE’ function, details are listed at following.

https://docs.aws.amazon.com/redshift/latest/dg/CONVERT_TIMEZONE.html

For example, your simple query to convert sales from UTC to EST would be something like below.

It will return something like below.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement