COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: krevix on 03 Aug 2023 06:02:39 AM

Title: Converting a Date Calculation to a number/string
Post by: krevix on 03 Aug 2023 06:02:39 AM
Hi all

I have 2 dates that I am subtracting from one another to get a date difference: My expression is: current_date -[DUE_DATE] this gives me the correct result but its an interval like "5 Days"

I want to remove the Days and just get the number eg: "5 Days" --> "5"

I tried the day function but it's not supported, also tried cast to integer and im not getting good results.

Any idea?
Title: Re: Converting a Date Calculation to a number/string
Post by: MFGF on 03 Aug 2023 07:12:09 AM
Quote from: krevix on 03 Aug 2023 06:02:39 AM
Hi all

I have 2 dates that I am subtracting from one another to get a date difference: My expression is: current_date -[DUE_DATE] this gives me the correct result but its an interval like "5 Days"

I want to remove the Days and just get the number eg: "5 Days" --> "5"

I tried the day function but it's not supported, also tried cast to integer and im not getting good results.

Any idea?

Hi,

There is a Cognos function _days_between() that returns the difference in days between two dates.

_days_between(current_date, [DUE_DATE])

Cheers!

MF.