Range of hours a period ...

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Wed, 21 Jul 2004 4:25 pm

Is there any function that calculates the range ... Ex. of intervals (7/21/2004 09:00 the 7/20/2004 18:00) I'm trying to use the function MONTHS_BETWEEN, but I don't know if that's more appropriate.

I thank all you can give me a hand ...
fernando
Location: Paraiso - SP

Poston Wed, 21 Jul 2004 4:38 pm

Yes. Use the-(minus) sign if u wanna know the difference in HOURS between two dates, do it like this:
Code: Select all
SQL> SELECT (TO_DATE('21/07/04 09:00', 'DD/MM/RR HH24:MI')
  2         -TO_DATE('20/07/04 18:00', 'DD/MM/RR HH24:MI')) *24 HORAS
  3  FROM DUAL;

     HORAS
----------
        15

1 row selected.
I multiplied by 24 because it returns the value in days, i.e. 3:0 pm =. 625 days. Then just multiply by 24 to get in hours ... If you want to have the results in minutes, multiply that by 60.

Code: Select all
SQL> SELECT (TO_DATE('21/07/04 09:00', 'DD/MM/RR HH24:MI')
  2         -TO_DATE('20/07/04 18:00', 'DD/MM/RR HH24:MI')) *24 *60 MINUTOS
  3  FROM DUAL;

   MINUTOS
----------
       900

1 row selected.
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered



Return to SQL

Who is online

Users browsing this forum: No registered users and 2 guests