Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL: Getting the difference of two date fields in seconds.
In article <7mljdd$lt7$1_at_news.powerisp.com>, Jerel Thompson
<jthompson_at_poweruser.com> writes
>Hi,
>
> I have two date fields. A start date and an end date. How do I find
>the difference of the two dates in seconds in SQL? I am using Oracle 8.0
>for linux.
>
>
The difference between two dates is given in complete days i.e. 1 = 1 day. So to get seconds you multiply the result by (24 * 60 * 60) e.g .5 days = .5 * (24 * 60 * 60) seconds.
e.g.
SELECT (end_date - start_date) * (24 * 60 * 60) FROM my_table;
Andy
--
Andy Hardy. PGP key available on request
![]() |
![]() |