COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: xyz on 22 Jun 2016 04:22:23 AM

Title: Alternate by weekly sunday's logic in sql server, how to get same in Cognos 10.2
Post by: xyz on 22 Jun 2016 04:22:23 AM
Hi All,

I have a requirement to display bi weekly sunday's in the x-axis of the chart in Cognos 10.2.2 and data base is relational, SQL server. I have a logic of getting the alternate sunday's in sql server, not quite to sure how to implement the same in the Cognos, using Cognos functions.

dateadd(dayofyear,(8-datepart(weekday,cast(datepart(year, datecolumn) as varchar(10)) +'-01-01') % 7)
                     +(((datepart(dayofyear,datecolumn) - (8-datepart(weekday,cast(datepart(year,datecolumn) as varchar(10)) +'-01-01') % 7)+13) /14)*14-14)
                     ,cast(datepart(year,datecolumn) as varchar(10)) +'-01-01')

Can some one please help me to tweak the code in Cognos, which should serve my purpose.


Thanks in advance
Title: Re: Alternate by weekly sunday's logic in sql server, how to get same in Cognos 10.2
Post by: bdbits on 24 Jun 2016 10:19:02 AM
I don't see anything in there you should have any real difficulty replacing with Cognos functions. But if you are certain it will only ever be used with MSSQL (assuming that is your database), I think those are all supported pass-through functions.

http://www.ibm.com/support/knowledgecenter/SSEP7J_10.1.0/com.ibm.swg.im.cognos.ug_cr_rptstd.10.1.0.doc/ug_cr_rptstd_id49790cr_rptstd_expr_editor_expression_co.html#cr_rptstd_expr_editor_expression_components (http://www.ibm.com/support/knowledgecenter/SSEP7J_10.1.0/com.ibm.swg.im.cognos.ug_cr_rptstd.10.1.0.doc/ug_cr_rptstd_id49790cr_rptstd_expr_editor_expression_co.html#cr_rptstd_expr_editor_expression_components)