[AccessD] Age calculation function

rusty.hammond at cpiqpc.com rusty.hammond at cpiqpc.com
Thu Jul 31 15:34:17 CDT 2003


Just fyi, the age function on the c pearson website isn't completely
accurate.  For instance send it the following in the immediate window: ?
Age(#5/21/1968#,#7/20/2003#) and it returns 35 years 1 month and 31 days.

For your purposes (ie years) it may work fine.

Rusty

-----Original Message-----
From: jeffrey.demulling at usbank.com [mailto:jeffrey.demulling at usbank.com]
Sent: Thursday, July 31, 2003 2:59 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Age calculation function



check out www.cpearson.com/excel/DateTimeVBA.htm


 

                    "Mark Whittinghill"

                    <mwhittinghill at symphonyinf        To:
accessd at databaseadvisors.com                                       
                    o.com>                            cc:

                    Sent by:                          Subject:     [AccessD]
Age calculation function                            
                    accessd-bounces at databasead

                    visors.com

 

 

                    07/31/2003 02:52 PM

                    Please respond to "Access

                    Developers discussion and

                    problem solving"

 

 





Hi all,

  I need an age calculation function to calculate current age from
birthday.
If the person's 30th birthday is on August 1, I want them to be 29 on
July31st.  DateDiff rounds up and makes them 30.  I made this function

Public Function CalculateAge(datBirth As Date) As Long

    Dim lngNumDays As Long
    lngNumDays = DateDiff("d", datBirth, Date)

    CalculateAge = Int(lngNumDays / 365.25)

End Function


It works, except when today's date is their birthday.  In my example, on
their birthday, the function returns 29.  The next day it works.  It works
for some years on the birthday and not others.  How can I make this
foolproof?

Mark Whittinghill
Symphony Information Services
612-333-1311
mwhittinghill at symphonyinfo.com


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list