|
 |
access thread: Calculating age in Years & Months from date of birth/current date
Message #1 by thutt@s... on Mon, 28 Jan 2002 12:24:39
|
|
I am trying to build a student database which includes date of birth as
one of its fields. From this I want to use a query to show students age
in years and months.
Is there a solution?
Cheers
Tony
Message #2 by "Becky" <RDingwall@m...> on Mon, 28 Jan 2002 12:37:58 -0000
|
|
This is some formula I used in Excel once to calculate a person's age so
maybe it would be some help to you if you adapted it for Access.
End If
'add the formula to the 3rd column in here if there's any age data
If (NewWS.Cells(iRow, 2) <> "") Then
Dim form As String
form = "=INT((TODAY()-B" + CStr(iRow) + ")/365.25)"
NewWS.Cells(iRow, 3).Formula = form
End If
Next iRow
NextCol:
Next iCol
-----Original Message-----
From: thutt@s... [mailto:thutt@s...]
Sent: 28 January 2002 12:25
To: Access
Subject: [access] Calculating age in Years & Months from date of
birth/current date
I am trying to build a student database which includes date of birth as
one of its fields. From this I want to use a query to show students age
in years and months.
Is there a solution?
Cheers
Tony
Message #3 by "Becky" <RDingwall@m...> on Mon, 28 Jan 2002 12:41:00 -0000
|
|
Try this which I have just found:
Function Age(DOB As Variant)
' Returns the Age in years, for a person whose Date Of Birth is DOB.
' The expression following "+" is boolean for
NotHadBirthdayThisYear.
If IsDate(DOB) Then
Age = DateDiff("yyyy", DOB, Date) + (DateSerial(Year(Date),
Month(DOB),
Day(DOB)) > Date)
End If
End Function
OR try this
Format( Date() - DOB, "yy")
DateDiff("y", DOB, Date)
Int(DateDiff("d", DOB, Date)/365.25)
-----Original Message-----
From: thutt@s... [mailto:thutt@s...]
Sent: 28 January 2002 12:25
To: Access
Subject: [access] Calculating age in Years & Months from date of
birth/current date
I am trying to build a student database which includes date of birth as
one of its fields. From this I want to use a query to show students age
in years and months.
Is there a solution?
Cheers
Tony
Message #4 by "Gregory Serrano" <serranog@m...> on Mon, 28 Jan 2002 14:01:18
|
|
Tony,
> I am trying to build a student database which includes date of birth as
> one of its fields. From this I want to use a query to show students age
> in years and months.
In English (you need to transform this into Access VB using your
variables):
Actual Age = (Date Now - DOB) / 365.25
No. of Years = INTEGER(Actual Age)
No. of Months = INTEGER((Actual age - No. of Years) * 12)
Greg
Message #5 by "Ian Ashton" <ian@c...> on Mon, 28 Jan 2002 18:30:30 -0000
|
|
Tony,
If you use the inbuilt VB date manipulation facilities, the following will
give you your answers.
intYears = CInt(Format(Date - dtmBirthDte + 1, "yy"))
intMonths = CInt(Format(Date - dtmBirthDte + 1, "mm") - 1)
I prefer using this method rather than using the length of the year to be
365.25 days.
Ian Ashton
-----Original Message-----
From: thutt@s... [mailto:thutt@s...]
Sent: Monday, January 28, 2002 12:25 PM
To: Access
Subject: [access] Calculating age in Years & Months from date of
birth/current date
I am trying to build a student database which includes date of birth as
one of its fields. From this I want to use a query to show students age
in years and months.
Is there a solution?
Cheers
Tony
|
|
 |