Show average user age query


Well-known member
I used to use this on my old board to return the average age of the membership:
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?

Jake Bunce

XenForo moderator
Staff member
This would be the xenForo equivalent:

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.