I have a larger query that does not seem to be working correctly so I have reproduced the issue with this smaller select statement that seems to show the same odd behavior.
This select :
SELECT '2023-04-03T04:00:00.000Z'::timestamp at time zone 'UTC',
'2023-04-03T04:00:00.000Z'::timestamp at time zone 'UTC' at time zone 'America/New_York',
'2023-04-03T04:00:00.000Z'::timestamp at time zone 'UTC' at time zone 'America/New_York' at time zone 'UTC'
Should return the columns:
2023-04-03 04:00:00.000000
2023-04-03 08:00:00.000000
2023-04-03 04:00:00.000000
However it is returning
2023-04-03 04:00:00.000000
2023-04-03 08:00:00.000000
2023-04-03 08:00:00.000000
This makes no sense because it should be triple converting that last one. I have tried several variations of this including using the timestamptz data type and going from America/New_York back to UTC never works.
As mentioned above, I understand it seems stupid to be doing this, but part of a larger set of code needs to do something like this, primarily convert from a TZ back to UTC and it is not doing it properly. These queries are just simple tests that simulate what the much larger query is experiencing.