COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: vkraju on 24 Sep 2008 10:53:47 AM

Title: need help with date intervals
Post by: vkraju on 24 Sep 2008 10:53:47 AM
Hi all i have a problem in writing a if statement
example is:

If code = '1'
then
(date1-date2)
else
if code='2'
then
(date2-date3)
else
(' ')

cognos is giving an error.
how do i write the sql for this kind of time interval using a code.

thanks
Kris
Title: Re: need help with date intervals
Post by: blom0344 on 24 Sep 2008 01:28:42 PM
First , try to get used to CASE statements as these are easier to read then IF THEN ELSE.
There is a function called datediff for calculating difference between dates.
Did you take a look at the standard Cognos functions that are available?
Title: Re: need help with date intervals
Post by: the_xxx on 26 Sep 2008 05:37:58 PM
cast the date functions.... :)