|
|
|
Re: parameter not pass with time [message #644532 is a reply to message #644528] |
Mon, 09 November 2015 04:39 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
What do you expect this function to return? What to you call "total time"? Your code looks suspicious; did you test what it really does, step-by-step?
SQL> with test as
2 (select to_date('09.11.2015 11:33', 'dd.mm.yyyy hh24:mi') date_out,
3 to_date('09.11.2015 10:23', 'dd.mm.yyyy hh24:mi') date_in
4 from dual
5 )
6 select date_out - date_in result_1,
7 trunc(date_out - date_in) result_2,
8 trunc(date_out - date_in) * 24 result_3,
9 lpad(trunc(date_out - date_in) * 24, 2, 0) result_4
10 from test;
RESULT_1 RESULT_2 RESULT_3 RE
---------- ---------- ---------- --
,048611111 0 0 00
SQL>
When subtracting two dates, you get number of days. So, if you meant to return number of hours (which multiplying with 24 suggests), why did you TRUNC the difference first?
|
|
|
Re: parameter not pass with time [message #644533 is a reply to message #644530] |
Mon, 09 November 2015 04:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
The main problem with your code is the fact that you're using trunc. The why you're using it it does the same job as floor - remove all decimals. That's not what you want.
|
|
|
|
|
|
|
|
|
|