Hire me on UpWork

Monday, June 4, 2012

How to Calculate Average of Date Values ?

Do you getting trouble of calculating average time of a filed, where data type is date time ?
Don't worry. You are at right place to get right solution.

I'm calculation of average time of a filed. If there is two time value in a day, i will calculate the first one means minimum one.

SELECT TO_CHAR(TRUNC(SYSDATE)+AVG(VDATE-TRUNC(VDATE)),'HH24:MI:SS')
FROM (SELECT MIN(DDATE) VDATE
FROM DEPT
GROUP BY TRUNC(DDATE))

Make changes in the script as your need and try.

Hope this helps you in work. 

Leave comments if it helps you.

No comments:

Post a Comment