DatePart Function (1 Viewer)

RACHNA

Registered User.
Local time
Today, 04:35
Joined
Nov 18, 1999
Messages
12
I'm using the following code to compute Age based on Date of Birth. (i'm using 4 digit year)

Private Sub DOB_AfterUpdate()
Age.Value = DatePart("yyyy",[Now]) - DatePart("yyyy",[DOB])
End Sub

I'm getting bad results and realize I need to use month and day in the calculation.

Any ideas how?

Thanks!
 

CST9999

New member
Local time
Today, 04:35
Joined
Jan 21, 2000
Messages
5
Try this:
Days As Integer
Days = DateDiff("d", DOB, Date)
Days = Days / 365
Age.Value = Days

This should work for you.

[This message has been edited by CST9999 (edited 02-04-2000).]
 

RACHNA

Registered User.
Local time
Today, 04:35
Joined
Nov 18, 1999
Messages
12
I tried this code and I still get the same results. So I tried the following:

Age = DateDiff("yyyy", [DOB], Now()) + _
Int(Format(Now(), "mmdd") < Format([DOB], "mmdd"))

Thanks!

[This message has been edited by RACHNA (edited 02-04-2000).]
 

Users who are viewing this thread

Top Bottom