COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: pavan522 on 04 Jan 2014 11:51:19 PM

Title: Days Difference
Post by: pavan522 on 04 Jan 2014 11:51:19 PM
    Hi All,

          Here is my scenario...

                        I have  2 columns with product line and date
                             for ex
PL      Date      Days Difference
            
A      05-Jan-13      0
B      06-Jan-13      1
C      10-Jan-13      4
D      15-Jan-13      5

I need third columns as mentioned above.




Title: Re: Days Difference
Post by: HalfBloodPrince on 05 Jan 2014 11:36:51 PM
Try this

running-difference ([Date])
Title: Re: Days Difference
Post by: pavan522 on 06 Jan 2014 12:42:34 AM
Running-Difference is not working...
Title: Re: Days Difference
Post by: navissar on 06 Jan 2014 01:08:35 AM
Running-difference needs a numeric value.
So, how do we turn a date field to a numeric field? There are several methods. Since you are particularly interested in the days difference, I'd go with the following:
_days_between ([Date],1900-01-01)
What this will do is return the number of days since January 1st 1900, a date on which I'm fairly certain you have no relevant data, and the date in the Date field.
So, you'll want to do something like this:
running-difference(_days_between ([Date],1900-01-01))
Title: Re: Days Difference
Post by: lclove on 06 Jan 2014 07:49:41 PM
if  FM model
try
select t.datedate,
       lead(datedate) over(order by datedate) next_date,
       lead(datedate) over(order by datedate) - datedate difference