COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: callmenagendra on 03 Feb 2015 06:47:44 AM

Title: How to get previous year last month in cognos relational model?
Post by: callmenagendra on 03 Feb 2015 06:47:44 AM
How to get previous year last month in cognos relational model?
Title: Re: How to get previous year last month in cognos relational model?
Post by: MFGF on 03 Feb 2015 07:04:06 AM
Quote from: callmenagendra on 03 Feb 2015 06:47:44 AM
How to get previous year last month in cognos relational model?

Hi,

Last month as in the last month of the previous year (ie December 2014) or last month (ie January 2015) a year ago (ie January 2014)?

The answer is to code a filter based on current_date()

For example:

[your date item] between _first_of_month (_add_years(_add_months (current_date,-1),-1)) and _last_of_month (_add_years(_add_months (current_date,-1),-1))

This would return rows for January 2014

MF.
Title: Re: How to get previous year last month in cognos relational model?
Post by: callmenagendra on 11 May 2015 05:31:42 AM
Thank you very much
Title: Re: How to get previous year last month in cognos relational model?
Post by: peewan on 01 Apr 2020 02:25:41 PM
Quote from: MFGF on 03 Feb 2015 07:04:06 AM
Hi,

Last month as in the last month of the previous year (ie December 2014) or last month (ie January 2015) a year ago (ie January 2014)?

The answer is to code a filter based on current_date()

For example:

[your date item] between _first_of_month (_add_years(_add_months (current_date,-1),-1)) and _last_of_month (_add_years(_add_months (current_date,-1),-1))

This would return rows for January 2014

MF.


How can I get 'Last month as in the last month of the previous year (ie December 2014)'?? Thank you
Title: Re: How to get previous year last month in cognos relational model?
Post by: BigChris on 02 Apr 2020 01:45:33 AM
[Date] between _maketimestamp(_add_year(current_date,-1),12,1) and _maketimestamp(_add_year(current_date,-1,12,31)