Ovidiu is on the right track. I think the best answer though is:
record_date >= add_months(sysdate,-36)
I prefer to do the adjustment on the bind variable (which Oracle only
has to do once) rather than on the column value (which Oracle would have
to do for every record in the table).
-----Original Message-----
From: Ovidiu Turcean
[mailto:oracledba-ezmlmshield-x17859896.[Email address protected]
Sent: Friday, September 28, 2007 3:00 AM
To: LazyDBA Discussion
Subject: RE: current date minus exactly 3 years
1. If you do sysdate - t_date>1095, you'll get wrong results when leap
years come into play.
2. add_months has 2 arguments. I think the correct way would be
add_months(t_date, 36) <= sysdate
-----Original Message-----
From: Shadab Mehboob
[mailto:oracledba-ezmlmshield-x11781119.[Email address protected]
Sent: Friday, September 28, 2007 9:41 AM
To: LazyDBA Discussion
Subject: Re: current date minus exactly 3 years
Select records from table1 where sysdate - t_date>1095 or
select records from table1 where t_date>=(add_months(sysdate)+36)
Regards
Shadab
----- Original Message -----
From: "Ovidiu Turcean "
<oracledba-ezmlmshield-x18276174.[Email address protected]
To: "LazyDBA Discussion" <[Email address protected]
Sent: Friday, September 28, 2007 12:02 PM
Subject: RE: current date minus exactly 3 years
> Maybe
>
> SELECT *
> FROM table t
> WHERE months_between(SYSDATE, t.date_column) >= 36
>
>
> -----Original Message-----
> From: Alan Vervaeke
> [mailto:oracledba-ezmlmshield-x93019633.[Email address protected]
> Sent: Thursday, September 27, 2007 8:34 PM
> To: LazyDBA Discussion
> Subject: current date minus exactly 3 years
>
> Sorry, but I am experiencing intra-cranial flatulence.
>
>
>
> A simple query to select records where record date is greater than or
> equal to sysdate minus 3 years??
>
>
>
> Anyone? Bueller ?? Bueller ??
>
>
>
> Alan
>
>
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> To post a dba job: http://jobs.lazydba.com
> To Subscribe : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> To post a dba job: http://jobs.lazydba.com
> To Subscribe : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
>
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
THE INFORMATION CONTAINED IN THIS E-MAIL MESSAGE AND ANY ATTACHMENTS SENT FROM GENTEX CORPORATION IS GENTEX CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE PERSONAL USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE. If you are not the intended recipient, you are hereby notified that any review, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail, and delete this e-mail message and any attachments from your computer.
Oracle LazyDBA home page