We are using Oracle 11g and we have a table with a timestamp column which doesn’t contain the timezone (simply defined as TIMESTAMP). The timezone is written in a different column.
I want to be able to use the ‘max’ function while taking the timezone into account.
There’s probably a function to convert timezones easily and I just don’t know it.
I want to be able to do something like this:
SELECT max(covert_to_timezone(my_timestamp, my_timezone, 'GMT')) FROM my_table
How can I do that?
==================
Solution: According to Ajith Sasidharan’s answer:
SELECT max(from_tz(my_timestamp, my_timezone) at time zone '0:00') FROM my_table
Update: If you want to compare dates, simply use ‘cast’:
SELECT max(from_tz(cast(my_date as timestamp), my_timezone) at time zone '0:00') FROM my_table
Btw, now I got ‘ORA 01878’ errors, meaning our table contains invalid times (DST shit).
I guess you want a function like this ::