Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

oracle date- total elapsed time calculation

Posted on 2012-03-28
11
Medium Priority
?
633 Views
Last Modified: 2012-03-28
http://www.experts-exchange.com/Database/Oracle/Q_27543396.html
Already answered.

      :total_elapsed_time :=

select to_char(to_date('00:00:00','HH24:MI:SS')
 + (:filtration_end - :filtration_start), 'HH24:MI');                  
 
start 3/28/2012 9:13:52 AM
 
 end 3/28/2012 9:20:00 AM
Its giving me 00:06
but its seven minutes. Need help in fixing this
0
Comment
Question by:anumoses
  • 5
  • 4
  • 2
11 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 37777770
It's neither 6 minutes nor 7 minutes.

it's 6 minutes and 8 seconds.

however.  your format  HH24:MI  means you are only displaying the minutes and are dropping the seconds
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 1000 total points
ID: 37777779
change this portion...

:filtration_end - :filtration_start


to

trunc(:filtration_end,'mi') - trunc(:filtration_start,'mi')
0
 
LVL 6

Author Comment

by:anumoses
ID: 37777798
trunc(:filtration_end,'mi') - trunc(:filtration_start,'mi')

Will this give 6 minutes and 8 seconds.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 74

Expert Comment

by:sdstuber
ID: 37777815
no

for one, even if the calculation did preserve the seconds, the HH24:MI format in the TO_CHAR didn't change, and that's why you don't see the seconds.

second, truncation removes the seconds so the math is at the minute level only

third - just try it,  always test for yourself.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37777827
Do you want 6 minutes and 8 seconds?  In the other question you said you did not want seconds.

If you do just add seconds to the format:

select to_char(to_date('00:00:00','HH24:MI:SS')
 + (:filtration_end - :filtration_start), 'HH24:MI:SS');

If you do not want the seconds and want it rounded up then sdstuber's post will work.
0
 
LVL 6

Author Comment

by:anumoses
ID: 37777841
I want minutes and seconds
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37777850
>>> I want minutes and seconds


then why did you ask for 7 minutes?


when you change the requirements like that -you completely invalidate previous effort and turn correct answers into wrong answers.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37777852
>>I want minutes and seconds

That is not what you asked for initially...

anyway:  http:#a37777827
0
 
LVL 6

Author Comment

by:anumoses
ID: 37778064
Its my mistake. it was gicing 00:06 So I said wanted 7 minutes.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37778112
I suggest continuing with this question as originally asked
and then opening a new question to include the seconds.

that way the original posts, which apply to the original question will still be valid,  and slightwv can repost in the other question with his suggestion for the new requirement
0
 
LVL 6

Author Closing Comment

by:anumoses
ID: 37778408
Will post another one for slightvw to answer
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question