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

Rolling 3 month 1

Status
Not open for further replies.

mcdac1

Programmer
May 12, 2008
5
US
I have a report which we only want the last three months of data from the date it's ran. So if I run it today June 9 it will have all data back to March 9. Thanks for your help.
 
How do you define 3 months in your case?

One possible solution:

Code:
extract(day,current_date-[somenamespace].[somedate])
between
(CASE
     WHEN
         extract(month,current_date) in (1,7,8,10,12)
     THEN 92
     WHEN
         extract(month,current_date) in (2,4,6,9,11)
     THEN 91
     WHEN
         extract(month,current_date) in (3,5)  
     THEN 90
     ELSE 89 
END)

Ties Blom

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top