COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Framework Manager => Topic started by: blom0344 on 12 Jul 2007 02:54:49 PM

Title: [FM] subtract 2 dates oracle style to come up with day-fraction
Post by: blom0344 on 12 Jul 2007 02:54:49 PM
Basically, when you subtract 2 dates in Oracle the result returned is the fraction in days (provided time portion is filled)

I need this time difference to based calculations on.

Framework only accepts this subtraction when local processing is activated, but then it returns a time interval which is the duration formatted to a nice format useless to perform calcs on.

Anyone an idea how  to solve this?
Title: Re: [FM] subtract 2 dates oracle style to come up with day-fraction
Post by: blom0344 on 12 Jul 2007 03:36:03 PM
Cognos KB has a reference 1029733.1  on this topic.
From within Framework manager setting the format of TIME INTERVAL to a specific format (such as minutes) does not change the way the outcome of the subtraction is presented. But I hope it is correctly presented within the studios...
Title: Re: [FM] subtract 2 dates oracle style to come up with day-fraction
Post by: blom0344 on 19 Jul 2007 03:11:27 PM
Works as designed   ;)
Title: Re: [FM] subtract 2 dates oracle style to come up with day-fraction
Post by: MFGF on 20 Jul 2007 01:53:56 AM
In Impromptu, I remember having to use the DAY function on the interval to extract the day part as an integer before using in further calculations.  Probably worth a try here too, although you'd probably need to use the extract function rather than the day function

eg: extract(day, ([date2] - [date1])

Regards,

MF.
Title: Re: [FM] subtract 2 dates oracle style to come up with day-fraction
Post by: blom0344 on 20 Jul 2007 03:33:25 AM
Thank you , that seems to work quite nicely.

To sum up what we tested (for Oracle):

Calculation 1:  "Whole days without having to switch on local processing"

to_char([namespace].[namespace1].[Date1];'J') - to_char([namespace].[namespace1].[Date2];'J')

Calculation 2:  "Whole days and being forced to switch on local processing":

extract(day,[namespace].[namespace1].[Date1]-[namespace].[namespace1].[Date2])

Calculation 3:  "Timeinterval to be formatted and being forced to switch on local processing":

[namespace].[namespace1].[Date1]- [namespace].[namespace1].[Date2]

Calculations 2 and 3 seem to have the same use.
However, the datatype of calculation2  is Int32,  and that of calculation3 is Time Interval