Home » SQL & PL/SQL » SQL & PL/SQL » Finding Records 60 days back from sysdate
Finding Records 60 days back from sysdate [message #454] Wed, 13 February 2002 08:57 Go to next message
Tom
Messages: 67
Registered: June 1998
Member
Hi,

I have a simple question. I need to select records
that are within 60 days back from the sysdate. So basically
a select statement:

Select partnum from part_table
where to_date >= sysdate - 60 days

How do I write the where clause?
Re: Finding Records 60 days back from sysdate [message #457 is a reply to message #454] Wed, 13 February 2002 12:44 Go to previous messageGo to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
without "days" your statement will work correctly:

Select partnum from part_table
where to_date >= sysdate - 60
Re: Finding Records 60 days back from sysdate [message #479 is a reply to message #457] Thu, 14 February 2002 23:17 Go to previous message
Abul Fazal
Messages: 39
Registered: February 2002
Member
Select partnum from part_table
where trunc(to_date('column_name', 'Format')) >= trunc(sysdate - 60 )

Is a safer option in that the time will be ignored.
Previous Topic: loops and cursors
Next Topic: improving performance of a query
Goto Forum:
  


Current Time: Thu Sep 23 13:33:15 CDT 2021