COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: pooja on 15 Jan 2010 09:40:43 AM

Title: regarding date diff
Post by: pooja on 15 Jan 2010 09:40:43 AM
how can I get the date diff from this table


id_no    state    time    process_code
-----------------------------------------

01         TX    12-01-09    1
02         TX    12-15-09    4
03         TX   12-21-09     4
03         AZ   10-01-09     1
05         NY   05-10-09     13
06         NY   11-12-12     21

how can I get time difference for (in days)

TX  from process_code 1 to process_code 4 (latest process code)

and

NY from process_code 13 to process_code 21


thank you so much in advance
Title: Re: regarding date diff
Post by: pooja on 15 Jan 2010 10:51:16 AM
 :o
Title: Re: regarding date diff
Post by: MFGF on 15 Jan 2010 11:14:09 AM
You could try the following:

Group on State.
Add two query calculations - Earliest Date - with the expression minimum([Time] for [State])
                                     - Latest Date - with the expression maximum([Time] for [State])

You could then work out the difference between these two calculated columns using a _days_between function in another calculation.

Regards,

MF.