COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: jaymoore1756 on 26 Feb 2015 11:12:47 AM

Title: Calculating minutes out of service using a date time field
Post by: jaymoore1756 on 26 Feb 2015 11:12:47 AM
I have two fields 1) creation_date_time and 2) close_date_time. Both fields are formatted as Date Time. The Creation field records the start of an incident (i.e. Feb 23, 2015 4:28:23 PM ) and Close field records the end of the incident (i.e. Feb 24, 2015 12:11:37 PM) . From these fields I need to calculate the minutes that the incident took to resolve. What do I need to do to convert these fields and calculate the time ?  Thanks for the help in advance.
Title: Re: Calculating minutes out of service using a date time field
Post by: Robl on 27 Feb 2015 02:50:36 AM
If you just delete one from the other you should get an interval.
Then you can just set the display format for it, or possibly use an extract funtion to get the minutes of the interval as an integer.

Title: Re: Calculating minutes out of service using a date time field
Post by: BigChris on 27 Feb 2015 03:17:46 AM
Try this one on for size

http://www.cognoise.com/community/index.php/topic,7912.msg25908.html#msg25908
Title: Re: Calculating minutes out of service using a date time field
Post by: jaymoore1756 on 01 Mar 2015 09:37:19 AM
I used this ...

if ([CLOSE_DATETIME] is not null ) Then ((extract(hour,[CLOSE_DATETIME])*60+extract(minute,[CLOSE_DATETIME]))-(extract(hour,[CREATION_DATETIME])*60+extract(minute,[CREATION_DATETIME])) +_days_between ([CREATION_DATETIME],[CLOSE_DATETIME])*1440) else ('0')
and got this error ( see attachment ) Any thoughts

Title: Re: Calculating minutes out of service using a date time field
Post by: jaymoore1756 on 02 Mar 2015 08:22:35 PM
This the error .....
XQE-DAT-0001

      Data source adapter error: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 11
ORA-30076: invalid extract field for extract source
- when processing query: WITH



Title: Re: Calculating minutes out of service using a date time field
Post by: BigChris on 03 Mar 2015 02:18:06 AM
Well for a kickoff I wouldn't put the zero in quotes - there's no need for it to be a string and that's probably throwing the rest of the calculation.
Title: Re: Calculating minutes out of service using a date time field
Post by: jaymoore1756 on 03 Mar 2015 10:03:52 AM
Reset the calculation to .... if ([CLOSE_DATETIME] is not null ) Then ((extract(hour,[CLOSE_DATETIME])*60+extract(minute,[CLOSE_DATETIME]))-(extract(hour,[CREATION_DATETIME])*60+extract(minute,[CREATION_DATETIME])) +_days_between ([CREATION_DATETIME],[CLOSE_DATETIME])*1440) else (0) Ran the validate on the data item and got the error
XQE-DAT-0001

      Data source adapter error: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 11
ORA-30076: invalid extract field for extract source

Framework shows the following .. for the extract sources (CLOSE_DATETIME, CREATION_DATETIME 
data type  -- Date Time
Usage -- Identifier
Size  --- 12
Format is date time with defaults




Title: Re: Calculating minutes out of service using a date time field
Post by: jaymoore1756 on 17 Mar 2015 08:51:16 AM
I am still trying to get this calculation to work ---

I have reset the calculation to .... if ([CLOSE_DATETIME] is not null ) Then ((extract(hour,[CLOSE_DATETIME])*60+extract(minute,[CLOSE_DATETIME]))-(extract(hour,[CREATION_DATETIME])*60+extract(minute,[CREATION_DATETIME])) +_days_between ([CREATION_DATETIME],[CLOSE_DATETIME])*1440) else (0)
Ran the validate on the data item and got the error
XQE-DAT-0001
Data source adapter error: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 11
ORA-30076: invalid extract field for extract source

Framework shows the following formatting for the extract sources (both are the same)
CLOSE_DATETIME, CREATION_DATETIME 

data type  -- Date Time
Usage -- Identifier
Size  --- 12
Format is date time with defaults
When I run the report I this is an example of the output I get
CREATION_DATETIME   Mar 15, 2015 4:26:15 PM   
CLOSE_DATETIME  Mar 15, 2015 9:21:51 PM
When I start to break the components of the formula down I get the following
Example 1 extract ( Year,[CREATION_DATETIME]) gives me data ie 2015
Example 2 extract ( day,[CREATION_DATETIME]) gives me data ie 7    
Example 3 extract (Hour,[CREATION_DATETIME]) gives me ...

XQE-DAT-0001

Data source adapter error: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 11
ORA-30076: invalid extract field for extract source

So it appears that there is an issue in the hour minute part of the calculation . Has anyone seen this ?


Title: Re: Calculating minutes out of service using a date time field
Post by: BigChris on 17 Mar 2015 09:33:27 AM
Do you get the same error is you try extract(Hour, getdate()) {or possibly extract(Hour, sysdate())...looks like you're using an Oracle database}?
Title: Re: Calculating minutes out of service using a date time field
Post by: jaymoore1756 on 17 Mar 2015 04:09:19 PM
Neither of these work ..extract(Hour, getdate()) {or possibly extract(Hour, sysdate())...
Title: Re: Calculating minutes out of service using a date time field
Post by: BigChris on 18 Mar 2015 03:19:44 AM
Ok - so it looks like there's something wrong with extract (hour, [SomeDate]) then since extract(hour, getdate()) isn't using any of the data from your database.
Title: Re: Calculating minutes out of service using a date time field
Post by: jaymoore1756 on 20 Mar 2015 11:49:10 AM
Thanks for trying to help BICHRIS !!! I think there is something wrong with the data element I am able to extract year day but I cannot extract hour minute. Is there a work around ?