G
Guest
I am trying to set up access to calculate ages. Does anyone have an idea on
how to do this?
how to do this?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I am trying to set up access to calculate ages. Does anyone have an idea on
how to do this?
=BAge: Int((DateDiff("d",[Birthdate],Now())/365.25))
Where [birthdate] is a text field and [bAge] is a second column in a query
John said:On Tue, 29 Nov 2005 11:00:18 -0800, Edwin Huellstrounk <Edwin
I am trying to set up access to calculate ages. Does anyone have an
idea on how to do this?
You should not store the age anywhere - if you do, it will be wrong
next year anyway.
Store the DOB (Date Of Birth) field in a Date/Time field and use a
calculated field in a Query:
Age: DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)
The IIF function corrects the age if the birthdate has not yet arrived
this year.
John W. Vinson[MVP]

=DateDiff("yyyy",[Birthdate],Now())+Int(Format(Now(),"mmdd")<Format([Birthdate],"mmdd"))
Same method, just a different syntax![]()
John said:=DateDiff("yyyy",[Birthdate],Now())+Int(Format(Now(),"mmdd")<Format([Birthdate],"mmdd"))
Same method, just a different syntax![]()
I used to, but someone pointed out that True is -1 in JET, +1 in
SQL/Server - so it limits the validity!
Works just fine in Access though and is likely a bit quicker, too.

It wouldn't matter since Int() would return 1 for 1 and -1 wouldn't it?
![]()
John said:Nope. Abs() would, but Int() just truncates any fractional part:
?int(-1)
-1
?int(-1.1)
-2
?int(-0.9)
-1
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.