Converting GMT AUD$ date to Local Time
25419Jun 21 2007 — edited Jun 22 2007In 10g, Oracle automatically stores its login audits in AUD$ in GMT and I need to
be able to display that in local time for the server (EST, PST, CST). I am showing
the last successful login and the unsuccessful logins in between the last and
current login.
-- last successful login
Select userid, max(to_char(ntimestamp#,'DD-MON-YYYY hh24:mi:ss'))
FROM sys.AUD$
WHERE userid = USER
AND returncode = 0
AND logoff$time is not null
GROUP BY userid;
-- last unsuccessful login
Select userid, max(to_char(ntimestamp#,'DD-MON-YYYY hh24:mi:ss'))
FROM sys.AUD$
WHERE userid = USER
AND returncode > 0
AND (ntimestamp# > :login_info.last_login)
I thought I could use SESSIONTIMEZONE to convert the AUD$ table field to
current time. I am under the impression this indicates the current session time
difference from the current GMT. So far we have not applied DST and its off by 1
hour here.
Select SESSIONTIMEZONE from dual;
-05:00
However, I now realize that when looking at audits that may be before DST took
affect this year, I may need to consider more to display what local time was at
that day it stored the GMT record to display it in the Local time that day.
Has anyone else done this? Even just converting local time from GMT stored only
five minutes ago.