Author Topic: 2 Months ago date filter  (Read 526 times)

Offline Taboka

  • Full Member
  • ***
  • Posts: 17
  • Forum Citizenship: +0/-0
2 Months ago date filter
« on: 25 Jan 2008 05:39:25 pm »
Hi all,
I am using the filter below to get values for 2 months ago:
[Recharge Monthly].[Time Month].[Time Month Key]=(if( substring(to_char(?FromDate?),5,2) = 01)
then ((?FromDate? - 89)-1)
else if( substring(to_char(?FromDate?),5,2) = 02)
then (?FromDate? - 89)
else (?FromDate? - 2))

It works for the instance where the month selected is January,i.e I get results for the previous Dec.However when I test it on the instance where the month selected is Feb(where I'm supposed to get results for the previous Dec),it doesn't return any results.
Could someone maybe help me figure that one out.

Thanks\Regards

Taboka

Offline Taboka

  • Full Member
  • ***
  • Posts: 17
  • Forum Citizenship: +0/-0
Re: 2 Months ago date filter
« Reply #1 on: 28 Jan 2008 06:32:57 pm »
Hi everyone,
I realised the problem was my math in calculating the previous Dec from a selected month of Feb.The correct filter is therefore
[Recharge Monthly].[Time Month].[Time Month Key]=(if( substring(to_char(?FromDate?),5,2) = 01)
then ((?FromDate? - 89)-1)
else if( substring(to_char(?FromDate?),5,2) = 02)
then (?FromDate? - 90)
else (?FromDate? - 2))
and it works like a charm.

Hope this helps someone.

Cheers
Taboka

Offline nishu85

  • Associate
  • **
  • Posts: 2
  • Forum Citizenship: +0/-0
Re: 2 Months ago date filter
« Reply #2 on: 08 Feb 2008 03:40:38 am »
you could have used add_months([date item] , -2 ) for that

Offline COGNOiSe administrator

  • Administrator
  • Statesman
  • ******
  • Posts: 677
  • Forum Citizenship: +31/-8
    • BrightStar Partners, Inc
Re: 2 Months ago date filter
« Reply #3 on: 09 Feb 2008 02:43:54 am »
Add_months and other add_* functions are great indeed.