Re: Averaging dates

From: Chrysalis <cellis_at_clubi.ie>
Date: Tue, 06 Aug 2002 19:26:17 GMT
Message-ID: <060820022029030019%cellis_at_clubi.ie>


In article <WB4Z8.61099$BD1.5521513_at_news1.calgary.shaw.ca>, Ron Gardiner <rongardiner_at_shaw.ca> wrote:

> Hope someone can help...
>
> How do I average a column of datatype date?
>
> SELECT AVG(HIREDATE) FROM EMPLOYEE; doesn't work.
>
> TIA!
Do people who post answers to questions ever try their answers?

The correct way to achieve this is:
select anydate+avg(date_column - anydate) from ...

anydate is any date literal or pseudo literal: try sysdate

date_column is the column whose value you are trying to average

note that the expression being averaged is a numeric value (number of days)

you may (or may not) want to display the fractional part of the result (e.g. in hours): choose an appropriate to_char() mask for the whole expression

-- 
Chrysalis
Received on Tue Aug 06 2002 - 21:26:17 CEST

Original text of this message