Print Page | Close Window

Member Profile - Show Correct Age

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums Modifications
Forum Description: Mod's and Add-on's for Web Wiz Forums.
URL: https://forums.webwiz.net/forum_posts.asp?TID=22120
Printed Date: 29 March 2026 at 10:57pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Member Profile - Show Correct Age
Posted By: DanW
Subject: Member Profile - Show Correct Age
Date Posted: 05 December 2006 at 12:17pm

Hi,

In the member profile, it was pointed out to me that the member's age was not always correct. If you were in the month they were born, and had not yet reached their birth date, then their age would be incorrect and would be the age they would be at their next birthday.

To fix this add the following function at the end of member_profile.asp:

<%

Function ExactAge(BirthDate)

    Dim yer
    Dim mon
    Dim d
    Dim dt

        dt = CDate(BirthDate)
        If dt > Now Then Exit Function
    
        yer = Year(dt)
        mon = Month(dt)
        d = Day(dt)
        yer = Year(Date) - yer
        mon = Month(Date) - mon
        d = Day(Date) - d
   
        If Sgn(d) = -1 Then
            d = 30 - Abs(d)
            mon = mon - 1
        End If
   
        If Sgn(mon) = -1 Then
            mon = 12 - Abs(mon)
            yer = yer - 1
        End If
   
    ExactAge = yer

End Function

%>


Find this line:

intAge = Fix(DateDiff("m", dtmDateOfBirth, now())/12)

and replace it with:

intAge = ExactAge(dtmDateOfBirth)

The member's correct age will now be displayed.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net