Home » Developer & Programmer » Forms » Minutes Calculation
Minutes Calculation [message #290583] Sun, 30 December 2007 01:32 Go to next message
sd_md_faizan
Messages: 19
Registered: 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 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you solved your problem?

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 Go to previous messageGo to next message
sd_md_faizan
Messages: 19
Registered: 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 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account 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 Go to previous messageGo to next message
sd_md_faizan
Messages: 19
Registered: February 2006
Location: Saudi Arabia
Junior Member
Thanks for your response,
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 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account 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: Fri Sep 27 10:31:33 CDT 2024