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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minus dates from sysdate

Status
Not open for further replies.

kloner

Programmer
May 15, 2000
79
AU
Hi all,

I guess this is a simple thing to do, but I am having trouble.

I want to do the following in a SQL statement in Oracle.

1. Select * from tbl_blah where
AUDIT_TIMESTAMP < (sysdate - x days)


2. Select * from tbl_blah where
AUDIT_TIMESTAMP < (sysdate - x months)


3. Select * from tbl_blah where
AUDIT_TIMESTAMP < (sysdate - x years)


Any help appreciated.

Regards,

kloner
 
1. Select * from tbl_blah where
AUDIT_TIMESTAMP < trunc(sysdate - x_days)

2. Select * from tbl_blah where
AUDIT_TIMESTAMP < trunc(sysdate - x_months * 30)

3. Select * from tbl_blah where
AUDIT_TIMESTAMP < trunc(sysdate - x_years * 365) love everyone til they prove otherwise, sadly some prove otherwise SO quickly
 
1. Select * from tbl_blah where
AUDIT_TIMESTAMP < trunc(sysdate - x_days)

2. Select * from tbl_blah where
AUDIT_TIMESTAMP < add_months(trunc(sysdate,-x_months))

3. Select * from tbl_blah where
AUDIT_TIMESTAMP < add_months(trunc(sysdate,(-x_months * 12))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top