COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: dollipi on 20 Jan 2014 06:53:21 AM

Title: last month
Post by: dollipi on 20 Jan 2014 06:53:21 AM
Hello,

does anyone know a function which always displays the last month?

Best regards,
D.
Title: Re: last month
Post by: charon on 20 Jan 2014 08:08:54 AM
hi,

try
[month] = (extract(month;current_date)-1)

cheerz
Title: Re: last month
Post by: BigChris on 20 Jan 2014 08:58:29 AM
Quote[month] = (extract(month;current_date)-1)
Does that work for January?

I'd use something more along the lines of:

[month] = (extract(month;_add_month(current_date,-1)))
Title: Re: last month
Post by: charon on 20 Jan 2014 09:04:52 AM
Your correct Chris ;)
Just copy/pasted it from a prompt query for year...for months you are absolutly correct. ;D
Title: Re: last month
Post by: dollipi on 20 Jan 2014 09:25:10 AM
it works, many thanks charon!