Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How to select from v$session records which logon_time is less than 2 days before current date?

SELECT * FROM v$session WHERE logon_time + 2 <= currentDate (???)
share|improve this question
    
Are you looking for sysdate ? docs.oracle.com/cd/B19306_01/server.102/b14200/functions172.htm –  a1ex07 Jun 10 '12 at 17:48
    
Maybe yes. But solved this as logon_time <= '8-JUN-12' and it works (needed only for homework). –  zgnilec Jun 10 '12 at 18:03
1  
More recent dates are greater than older dates so if you only want logins less than 48 hours and 0 seconds old, it should be WHERE logon_time + 2 > SYSDATE. As for, using '8-JUN-12' it's safer to explicitly convert that string to a date with something like: TO_CHAR('08-JUN-2012', 'DD-MON-YYYY'). –  George3 Jun 10 '12 at 18:07
    
I wanna logon_time older than 2 days. –  zgnilec Jun 10 '12 at 18:18
1  
And your "homework" will be accepted if you're asked to provide rows where login_time is less than 2 days before the current date, and you hard-code the date? Somehow I doubt it. Also, if you're asked to do this for homework, is it not in your learning materials? –  Aaron Bertrand Jun 10 '12 at 18:39

1 Answer 1

up vote 1 down vote accepted
WHERE logon_time <= sysdate - 2;

Or perhaps:

WHERE logon_time <= sysdate - interval '2' DAY;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.