Show average user age query

trilogy33

Well-known member
I used to use this on my old board to return the average age of the membership:
Code:
SELECT format(year(now()) - avg(right(birthday, 4)) , 2) AS Avg_Age
FROM user
WHERE right(birthday, 4) > '0000'
But of course that isn't going to work on XF.
Has anyone got an alternative that works please?
 
This would be the xenForo equivalent:

Code:
SELECT format(year(now()) - avg(dob_year) , 2) AS Avg_Age
FROM xf_user_profile
WHERE dob_year > 0

If you imported your old forum into xenForo then theoretically these two queries should return the same average age.
 
Top Bottom