COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: que1983 on 19 Jan 2016 11:57:07 AM

Title: Label to display date
Post by: que1983 on 19 Jan 2016 11:57:07 AM
_first_of_month(_add_months (current_date;-1))
this display the first day of last month in an expression.  Lets say I also want a label that displays the first day of last month as this
December 2015 or Dec 2015 or 12/2015 in the label.  How would I do this dynamically in the label portion in properties
Title: Re: Label to display date
Post by: Nagendar on 20 Jan 2016 03:49:44 AM
Hi que1983,

Dynamically means are you selecting date from any prompt...?

use layout calculation for dynamic display.

Thanks
Nagendar.
Title: Re: Label to display date
Post by: MFGF on 20 Jan 2016 05:28:25 AM
Quote from: que1983 on 19 Jan 2016 11:57:07 AM
_first_of_month(_add_months (current_date;-1))
this display the first day of last month in an expression.  Lets say I also want a label that displays the first day of last month as this
December 2015 or Dec 2015 or 12/2015 in the label.  How would I do this dynamically in the label portion in properties

Assuming this is a query calculation, you can use the Data Format property to define how your date is displayed :)

MF.
Title: Re: Label to display date
Post by: que1983 on 12 Mar 2016 10:46:35 AM
Can you provide an example
Title: Re: Label to display date
Post by: HalfBloodPrince on 14 Mar 2016 03:18:37 AM
You can try this  calculations

cast(extract(month,_first_of_month(_add_months (current_date;-1))),varchar(2)) +'/' +cast(extract(year,_first_of_month(_add_months (current_date;-1))),varchar(4))  will give you 2/2016
------------------------------------------------------------------------------------------------
or you try below to get output like Feb -2016 but have to make 12 cases one for each month
-------------------------------------------------------------------------------------------------
if(extract(month,_first_of_month(_add_months (sysdate(),-1)))=1) then
('JAN -' +cast(extract(year,_first_of_month(_add_months (sysdate(),-1))) ,varchar(4)) )

else
if(extract(month,_first_of_month(_add_months (sysdate(),-1)))=2) then

('FEB -' +cast(extract(year,_first_of_month(_add_months (sysdate(),-1))) ,varchar(4)) )

else
(Null)