Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateAdd in Oracle?

Status
Not open for further replies.

DVDGirl

Programmer
Mar 29, 2001
42
US
I'm trying to do this query:
DELETE FROM PHONE WHERE LOGINTIME<DateAdd(&quot;h&quot;,-2,Now())

(Basically, if someone's login time is more than two hours ago, I will assume that the user didn't log off, and I will delete their record...unless someone knows of a way to delete the record upon session timeout in ASP?) ;)

It works in Access, but it doesn't seem to work in Oracle. I get the error:
ERROR at line 1:
ORA-00904: invalid column name

Is there a way to do this? Any suggestions are greatly appreciated. Thank you in advance for any help.

-DVD Girl
 
DELETE FROM PHONE WHERE LOGINTIME< sysdate -2/24


sysdate - 1 would be one day ago
sysdate - 1/24 would be an hour ago
sysdate - 1/86400 would be a second ago I tried to remain child-like, all I acheived was childish.
 
Hi jimbopalmer -
That really helped me out. In my ASP page, I saved the field LOGINTIME as Now(), so the sql I made was:

DELETE FROM Phone WHERE logintime<(select to_char(sysdate-2/24,'MM/DD/YYYY HH:MI:SS PM') from dual)

Thanks again!

-DVD Girl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top