Andrew
11/14/2022, 11:41 PMTransactionHistory
for any transaction:
SELECT T.id transaction_id, TO_CHAR(MAX(TH.datetime), 'YYYY-MM-DD HH24:MI:SS TZR') latest_history_event, TO_CHAR(T.lastmodifieddate, 'YYYY-MM-DD HH24:MI:SS TZR') modifieddate
FROM TransactionHistory TH
JOIN Transaction T ON T.id = TH.transaction
GROUP BY T.id, T.lastmodifieddate
HAVING MAX(TH.datetime) != T.lastmodifieddate
ORDER BY T.lastmodifieddate DESC
The results are consistently returning "datetime" values (from the TransactionHistory table) and "lastmodifieddate" values (Transaction table) that are 3 hours apart, despite outputting the same timezone. Here's an example:
latest_history_event modifieddate
2022-11-14 14:37:11 AMERICA/NEW_YORK 2022-11-14 17:37:11 AMERICA/NEW_YORK
Probably not coincidentally, when I run
SELECT
TO_CHAR ( SYSDATE, 'DS TS' ) AS CurrentTimeServer,
TO_CHAR ( CURRENT_DATE, 'DS TS' ) AS CurrentTimeUser,
FROM
Dual
I get 'currenttimeserver': '11/14/2022 3:36:56 PM', 'currenttimeuser': '11/14/2022 6:36:56 PM'
Based on this, it seems that somehow, somewhere "datetime" is being interpreted in my timezone but then formatted with the timezone of the server 3 hours away. In other words, the resulting timestamp is simply wrong. Is there anyway to get a valid ISO timestamp (with a timezone) from the "datetime" field? Where is this implicit conversion happening?