COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: kwirth on 09 Aug 2016 03:13:24 PM

Title: Changing a variable into a date
Post by: kwirth on 09 Aug 2016 03:13:24 PM
I'm trying to figure out how to incorporate a year variable I have into a casting into a date.

I want to be able to type in the month and day, but insert the year that is in the data.

Ideally, I want to do something like this, but it doesn't work as is. Any thoughts?

cast('[YEAR]-01-09',date)
Title: Re: Changing a variable into a date
Post by: Lynn on 10 Aug 2016 02:18:47 AM
Quote from: kwirth on 09 Aug 2016 03:13:24 PM
I'm trying to figure out how to incorporate a year variable I have into a casting into a date.

I want to be able to type in the month and day, but insert the year that is in the data.

Ideally, I want to do something like this, but it doesn't work as is. Any thoughts?

cast('[YEAR]-01-09',date)



cast( [YEAR] || '-01-09' , date )



cast( [YEAR] || '-' || ?SelectMonth? || '-' || ?SelectDay? , date )


Something along these lines might help although zero padding in front of the entered values might be something you have to deal with.
Title: Re: Changing a variable into a date
Post by: AnalyticsWithJay on 10 Aug 2016 08:30:11 AM
One other solution is to try creating this expression using functions from your database vendor, because cast() is a locally-processed function, and could possibly degrade performance.