I know that at least in some SQL standards, the value expression (an argument to the AVG () function) cannot be a datetime value or a string value. I have not read all the SQL standards, but I would be surprised if this limitation loosened over the years.
In particular, this is because the "average" (or arithmetic mean) of the values ββof "n" is defined as the sum of the values ββdivided by "n". And the expression '01 -Jan-2012 08:00 '+ '03 -Mar-2012 07:53' makes no sense. Also there is no '01 -Jan-2012 08:00 '/ 3.
Microsoft products have a game history quickly and freely with SQL, exposing the internal representation of their date and time data types. Dennis Ritchie would call it "unreasonable implementation tricks."
In earlier versions of Microsoft Access (and possibly in current versions too), you could multiply the date '01 -Jan-2012 'by the date '03 -Mar-2012' and get the actual return value, supposedly in units of square dates.
If your dbms supports the interval data type, then averaging is simple and does what you expect. (SQL Server does not support interval data types.)
create table test ( n interval hour to minute ); insert into test values ('1:00'), ('1:30'), ('2:00'); select avg(n) from test; avg (interval)
source share