Home » SQL & PL/SQL » SQL & PL/SQL » Average of dates
Average of dates [message #39271] Tue, 02 July 2002 11:20 Go to next message
jack
Messages: 123
Registered: September 2000
Senior Member
I am attempting to derive the average of a date field based on all records in a table. The min() and max() work just fine now all I need is ...

select AVG(MyDate) from MY_TABLE;

I know the above does not work and that is why I am here. Any ideas? Convert the value to a number and then back to a date? If so what is the date to number conversion? I recall there is a way to get the difference from a fixed date in the past defined by the system but I don't recall the details.

TIA, Jack
Re: Average of dates [message #39272 is a reply to message #39271] Tue, 02 July 2002 12:18 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
select to_date(round(avg(to_char(mydate, 'j'))), 'j')   
  from my_table;
Re: Average of dates [message #39293 is a reply to message #39271] Wed, 03 July 2002 08:44 Go to previous message
jack
Messages: 123
Registered: September 2000
Senior Member
1,000 Thank you's !

I assume the 'j' is for Julian?
Previous Topic: Re: Delete Records - DJW
Next Topic: Changing Data Types
Goto Forum:
  


Current Time: Tue Apr 23 18:42:34 CDT 2024