I am trying to get round problem of the timestamp diff field giving incorrect rounding on hours and minutes. OBIEE won't provide any fucntions to resolve (hrs.minutes.seconds.
I used time stamp diff minutes and want to take total minutes and divide by 60, to get hours, so 70 mins would be 1.16' hours. Answers always rounds up, so this would become 2 hours. Is there a way of getting results to 2 decimal places.
1 st Attemp: TIMESTAMPDIFF(SQL_TSI_MINUTE,"Execution Plan Run"."Execution Plan Start Time" , "Execution Plan Run"."Execution Plan End Time")/60.000000000001
2 nd attempt: ROUND(cast(TIMESTAMPDIFF(SQL_TSI_MINUTE,"Execution Plan Run"."Execution Plan Start Time" , "Execution Plan Run"."Execution Plan End Time")/60 as real),3)
3 rd attempt: TIMESTAMPDIFF(SQL_TSI_MINUTE,"Execution Plan Run"."Execution Plan Start Time" , "Execution Plan Run"."Execution Plan End Time")/cast(60 as real)
Nothing is working out... then I tried in SQL Developer, somethiing like this:
SELECT TIME_IN_MIN,TRUNC(TIME_IN_MIN/60)||'HR'||' '||(TIME_IN_MIN - TRUNC(TIME_IN_MIN/60)*60)||'MINS' AS HR_MINS FROM TESTTIME;
In OBIEE >column propeties >edit properties fx> enter below sql
cast(cast(TRUNCATE(TIMESTAMPDIFF(SQL_TSI_MINUTE,"Execution Plan Run"."Execution Plan Start Time" , "Execution Plan Run"."Execution Plan End Time")/60, 0) as int) as char) || ' HR ' || cast(cast(TIMESTAMPDIFF(SQL_TSI_MINUTE,"Execution Plan Run"."Execution Plan Start Time" , "Execution Plan Run"."Execution Plan End Time") - (TRUNCATE(TIMESTAMPDIFF(SQL_TSI_MINUTE,"Execution Plan Run"."Execution Plan Start Time" , "Execution Plan Run"."Execution Plan End Time")/60, 0) * 60) as int)as char) || ' Min'
Note: As i mentioned earlier there is no report functionality in the front end to achive easily by using functions.This query will resolve the issue like rounding in OBIEE application.
Obrigado pelo post, funcionou muito bem
ReplyDeleteIn OBIEE 11g, rounding on hours and minutes can be achieved using calculated columns and functions. Godaddy Voucher To round hours, you can utilize the "TRUNC" function, which truncates the fractional part.
ReplyDelete