• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Show average user age query

trilogy33

Well-known member
#1
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?
 

Jake Bunce

XenForo moderator
Staff member
#2
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.