Home » SQL & PL/SQL » SQL & PL/SQL » URGENT!calculation of difference of time.
URGENT!calculation of difference of time. [message #365834] Tue, 15 February 2000 02:45 Go to next message
namrata
Messages: 1
Registered: February 2000
Junior Member
Is there a way to calculate the time difference between two date fields?Please help.
Re: URGENT!calculation of difference of time. [message #365835 is a reply to message #365834] Tue, 15 February 2000 05:06 Go to previous messageGo to next message
Marius Raicu
Messages: 2
Registered: February 2000
Junior Member
You can: select date2-date1 into variable from table;
What you mean by time difference exactly ?
Re: URGENT!calculation of difference of time. [message #365836 is a reply to message #365834] Tue, 15 February 2000 09:48 Go to previous messageGo to next message
K.krishnamoorthy
Messages: 3
Registered: December 1999
Junior Member
You can use pure SQl statement for it.

select to_number(to_char(todate,'HH24.MI'))-to_number(to_char(fromdate,'HH24.MI')) from dual

Note : do not use ":" in time format. it will treat it as Char.
Re: URGENT!calculation of difference of time. [message #365877 is a reply to message #365834] Wed, 01 March 2000 00:16 Go to previous messageGo to next message
Glenn J. Dean
Messages: 1
Registered: March 2000
Junior Member
This works to a point. The difference is calculated as an ascii difference not a numeric difference. I need to do this same thing but as a numeric difference. Can anyone fix this code to calculate a numeric difference instead of an ascii difference?

to_number(to_char(todate,'HH24.MI'))-to_number(to_char(fromdate,'HH24.MI'))

Thanks for the help.
Re: URGENT!calculation of difference of time. [message #365878 is a reply to message #365834] Wed, 01 March 2000 00:46 Go to previous message
K.krishnamoorthy
Messages: 3
Registered: December 1999
Junior Member
If minutes in 'todate' are less then minutes in fromdate ad 40 to it. This can be implemented by using DCODE.

Try it yourself.

Regards
Krishna
Previous Topic: how to insert a date and time field in SQL
Next Topic: Changing maximum size of buffer in the Put_Line procedure of the UTL_File package
Goto Forum:
  


Current Time: Fri Mar 29 06:12:00 CDT 2024