COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: Dampa on 10 Oct 2019 03:48:39 PM

Title: Filter for the last 7 days
Post by: Dampa on 10 Oct 2019 03:48:39 PM
Hi all,

I'm quite new with Cognos and I would need some tips before scheduling a report.

I would need to creare a filter so that only the last 7 days are displayed every time it runs.

The date is in the format yyyymmdd (i.e. 20191010). I'm assuming I need to convert the current date with that format and then take the range back to 20191010 - 7. At least this is what I'd do in Excel/Vba.

Thanks in advance for any advice you would share with me.

KR,
D
Title: Re: Filter for the last 7 days
Post by: Francis aka khayman on 10 Oct 2019 04:20:16 PM
convert to date and use _add_days
Title: Re: Filter for the last 7 days
Post by: Dampa on 11 Oct 2019 06:26:40 AM
Hi Francis,

Thanks for your feedback.

As I was saying, I'm really new with Cognos. Should I use somethig like to_date([Date], 'YYYYMMDD')?

Edit: I've tried [Business Date] between current_date and _add_days(current_date,-7) without success, where Business date is the real date taken from YYYYDDMM

Thanks,
Daniele
Title: Re: Filter for the last 7 days
Post by: Francis aka khayman on 11 Oct 2019 09:07:54 AM
use cast.

btw, google is very useful to find these info.
Title: Re: Filter for the last 7 days
Post by: dougp on 11 Oct 2019 10:46:41 AM
That won't produce results.  I suspect lacking knowledge about Cognos is not the problem.  You need to know something about how to use a database.

Try this:

You appear to have the correct syntax for _add_days, but for future reference:

You also need to know how BETWEEN works.

If that doesn't give you enough information:

Title: Re: Filter for the last 7 days
Post by: Francis aka khayman on 11 Oct 2019 11:46:57 AM
i'm a bit generous today

[Business Date] between _add_days(current_date,-7) and current_date