COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Framework Manager => Topic started by: gosoccer on 09 Feb 2017 03:27:31 AM

Title: How to obtain the Last Day of the Month in Relational Model
Post by: gosoccer on 09 Feb 2017 03:27:31 AM
Hi,
I'm trying to get the Last Day of the month using the below but getting an error.

If ([Physical View].[ANALYSIS].[TYPE_CD] ='1' and _last_of_month ([Physical View].[ANALYSIS].[Process_Date])) THEN
(1)
else
(0)
But getting an error saying, "Syntax error near ")""
Please help  if you can.

Thanks for your time. :) :)
Title: Re: How to obtain the Last Day of the Month in Relational Model
Post by: Lynn on 09 Feb 2017 03:46:55 AM
Quote from: gosoccer on 09 Feb 2017 03:27:31 AM
Hi,
I'm trying to get the Last Day of the month using the below but getting an error.

If ([Physical View].[ANALYSIS].[TYPE_CD] ='1' and _last_of_month ([Physical View].[ANALYSIS].[Process_Date])) THEN
(1)
else
(0)
But getting an error saying, "Syntax error near ")""
Please help  if you can.

Thanks for your time. :) :)


Your expression for the _last_of_month() function is correct, but you aren't comparing it to anything. If you consider what gets returned, your statement says something like this:


if ( TYPE_CD = '1' and 2017-02-28 )
then
(1)
else
(0)


You'd need to compare _last_of_month ( [Process_Date] ) with some other date value. Perhaps current_date? If so, try this:


If ( [Physical View].[ANALYSIS].[TYPE_CD] ='1' and _last_of_month( [Physical View].[ANALYSIS].[Process_Date] ) = current_date ) THEN
(1)
else
(0)

Title: Re: How to obtain the Last Day of the Month in Relational Model
Post by: gosoccer on 09 Feb 2017 03:54:30 AM
Ahh! Yes Lynn, that worked. Thx so much! It's 5 Am over here. I'm so glad I got an answer. Couldn't sleep.  :) :)