Author Topic: How to get previous year last month in cognos relational model?  (Read 5075 times)

Offline callmenagendra

  • Full Member
  • ***
  • Join Date: Jul 2014
  • Posts: 15
  • Forum Citizenship: +0/-0
How to get previous year last month in cognos relational model?

Offline MFGF

  • Never knowingly correct
  • Super Moderator
  • Statesman
  • ******
  • Join Date: Jul 2005
  • Posts: 10,977
  • Forum Citizenship: +652/-10
  • Cognos Software Muppet
Re: How to get previous year last month in cognos relational model?
« Reply #1 on: 03 Feb 2015 07:04:06 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.
Meep!

Offline callmenagendra

  • Full Member
  • ***
  • Join Date: Jul 2014
  • Posts: 15
  • Forum Citizenship: +0/-0
Re: How to get previous year last month in cognos relational model?
« Reply #2 on: 11 May 2015 05:31:42 am »
Thank you very much

Offline peewan

  • Senior Member
  • ****
  • Join Date: Aug 2019
  • Posts: 61
  • Forum Citizenship: +0/-0
Re: How to get previous year last month in cognos relational model?
« Reply #3 on: 01 Apr 2020 02:25:41 pm »
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

Offline BigChris

  • Statesman
  • ******
  • Join Date: Apr 2013
  • Posts: 1,206
  • Forum Citizenship: +87/-0
Re: How to get previous year last month in cognos relational model?
« Reply #4 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)

 



       
Twittear