Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: DATE column difference in minutes.
Guna Govind wrote:
>
> Hi,
> posting this on behalf of my colleque..
>
> I'm using Oracle7.3 on Solaris 2.5.1.
> I need to calculate the time difference in minutes from 2 character
> strings (basically the timestamp is stored in a 'C' program
> as a charcter string). I tried to convert the character string
> to "date" format using "to_date", and subtracted them. But it always
> subtracts the date portion of the timestamp, but not the time.That is,
> if I subtract two different times on the same date, I always
> get '0'.
>
> Any help on this, is greatly appreciated.
>
> Regards,
> Meena
Sounds like you are on the right track. Be sure to include the time portion in the format string in your TO_DATE function call, then subtract.
When you subtract two DATE format items in Oracle, you get the number of days, expressed as a floating-point number, including any fraction of days. Avoid truncating the fractional part, and multiply by the number of minutes in a day to get your answer.
![]() |
![]() |