COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cbyrne on 02 Sep 2010 04:46:33 PM

Title: Count the number of days between two dates in Cognos 8.2 Data Item
Post by: cbyrne on 02 Sep 2010 04:46:33 PM
Hello does anybody know how to count the numbers of days between two dates in a Data Item and in Report Studio 8.2.  The code below is for 8.4 but i do not have _days_between in the data item.

Data Item
_days_between(sysdate(),[DATEREPORTED])


Thanks

Chris
Title: Re: Count the number of days between two dates in Cognos 8.2 Data Item
Post by: technomorph on 02 Sep 2010 05:26:37 PM
Which DB?
Title: Re: Count the number of days between two dates in Cognos 8.2 Data Item
Post by: peritas-chris on 02 Sep 2010 10:27:38 PM
Use current_date, you should be able to use the _days_between function with that.

_days_between(current_date,[DATEREPORTED])
Title: Re: Count the number of days between two dates in Cognos 8.2 Data Item
Post by: Sreeni P on 03 Sep 2010 02:13:16 AM
Quote from: peritas-chris on 02 Sep 2010 10:27:38 PM
Use current_date, you should be able to use the _days_between function with that.

_days_between(current_date,[DATEREPORTED])

Hi first check what is [DATEREPORTED] column returning? check is that a date or a key? if that is not mapped with a date ? then u need to cast DATEREPORTED to DATE, then apply
the _days_between (sysdate(),[DATEREPORTED])

because sysdate is a DATE attribute with a timestamp

Hopes it fixes Ur problem
Title: Re: Count the number of days between two dates in Cognos 8.2 Data Item
Post by: cbyrne on 03 Sep 2010 03:59:02 AM
Thanks Guys this worked a treat i inserted _current_date into the data item and it worked fine.

Many Thanks

Chris
Title: Re: Count the number of days between two dates in Cognos 8.2 Data Item
Post by: peritas-chris on 03 Sep 2010 02:26:45 PM
No problem, glad to hear it worked for you!