Home » Developer & Programmer » Forms » Minutes Calculation
Minutes Calculation Sun, 30 December 2007 01:32
 sd_md_faizan Messages: 19Registered: February 2006 Location: Saudi Arabia Junior Member
hi,

I have the text data as follows

1) '01:50:34' i.e 1 hour, 50 Minutes and 34 Seconds,
2) '00:40:40' i.e 0 Hours, 40 Minutes and 40 Seconds

I need to convert this to average/sum hours or average miniutes or average seconds.

ex. to average minutes.
1) 110.34 => 110 Minutes and 34 Seconds.
2) 40.40 => 40 Minutes and 40 Seconds.

=> Summ as 151.14
=> Average as 75.57 (approximately)

I have done the above by using some simple calculations by using select statement. But I want to know whether there is any oracle function which converts such type of text data to Hours or Minuetes or Seconds. If any body knows please give the solution.

Thanks.
Re: Minutes Calculation [message #291790 is a reply to message #290583] Sun, 06 January 2008 22:48
 djmartin Messages: 10180Registered: March 2005 Location: Surges Bay TAS Australia Senior MemberAccount Moderator

Have you tried using an item of 'Data Type' = 'Datetime'?

David
Re: Minutes Calculation [message #302384 is a reply to message #291790] Mon, 25 February 2008 07:29
 sd_md_faizan Messages: 19Registered: February 2006 Location: Saudi Arabia Junior Member
hi David,
could you please give little bit more details.

Thanks,
Re: Minutes Calculation [message #302730 is a reply to message #302384] Tue, 26 February 2008 18:53
 djmartin Messages: 10180Registered: March 2005 Location: Surges Bay TAS Australia Senior MemberAccount Moderator
Sorry, datetime fields for the results will not handle your requirement because 'mi' has the range '0-59'.

Declare the input fields as datetime with a format of 'hh24:mi:ss' and the sum and average as number. Then use
```select to_number(to_char(:blk.datetime1-trunc(sysdate))) +
to_number(to_char(:blk.datetime2-trunc(sysdate)))
into :blk.sum_time
from dual;```
to get the sum as a number. Then use 'floor' and 'mod' to return the hour, minutes, and seconds.

David
Re: Minutes Calculation [message #302911 is a reply to message #302730] Wed, 27 February 2008 06:00
 sd_md_faizan Messages: 19Registered: February 2006 Location: Saudi Arabia Junior Member
approximately I did the same, But I want to know whether there is any pre-difined oracle function like SUM(), AVG() etc...

Thanks,
Re: Minutes Calculation [message #303817 is a reply to message #302911] Sun, 02 March 2008 23:27
 djmartin Messages: 10180Registered: March 2005 Location: Surges Bay TAS Australia Senior MemberAccount Moderator
Yes, look at the Server SQL Reference Manual.

David
 Previous Topic: Problem importing java class ... Next Topic: Deploy icon problem
Goto Forum:

Current Time: Sun Jul 23 02:10:28 CDT 2017

Total time taken to generate the page: 0.06353 seconds