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

Last 45 days filter

Status
Not open for further replies.

MSTRTD

Technical User
Sep 8, 2003
6
0
0
US
How to calculate the last 45 days from current date in a filter
thanks
 
Syntax dependant on your back-end database, but use an applysimple to filter the daterange
 
My back end is Teradata.
I was using
ApplyComparison ("#0 >= (select max(dte_key_num)-45 from views.time_detail from refrnc_dte < current_date ) AND #0 <=(select max(dte_key_num) from views.time_detail from refrnc_dte < current_date )", Date@[Date Key Num])

buts its not working.

Thanks
 
I haven't tested this but it looks like you have a "from" in place of a "where"

ApplyComparison ("#0 >= (select max(dte_key_num)-45 from views.time_detail from refrnc_dte < current_date ) AND #0 <=(select max(dte_key_num) from views.time_detail from refrnc_dte < current_date )", Date@[Date Key Num])
 
Agree with kpescatore, as you are using Current Date, then use dynamic dates. Current date - 45 days. Simple. It will make for more efficient SQL too as you will get a "DateField = 'ccyy-mm-dd' clause rather than a subquery.

I would only use the Applysimple here if youyr date table is not matching your current date - i.e. you plan to run after midnight and still call yesterday, today (and today's date is the latest value on the date table).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top