1. 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

Discussion in 'XenForo Questions and Support' started by trilogy33, Mar 23, 2011.

  1. trilogy33

    trilogy33 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?
  2. Jake Bunce

    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.
  3. trilogy33

    trilogy33 Well-Known Member

    Excellent thanks Jake, query works perfectly. :)
    I started with a new XF board from scratch.
  4. trilogy33

    trilogy33 Well-Known Member

Share This Page