Calculating Age In Access - New Problem

  • Thread starter Thread starter Ray
  • Start date Start date
R

Ray

I'm trying to calculate a person's age in a query as of Now
(). The following is my query.

Age: Format(Date(),"yyyy")-(Format([Birthdate],"yyyy"))

I tried Steves Schapel's Dec 15 reply to Al but I get the
same results I get with the above statement. The problem
is when I run the query today (Dec 16) and the person's
birthday is Dec 30, 1943 I get his age as 60 instead of
59. I understand why my query gives the results I get but
I don't know how to modify it to give the wanted results.
Thanks for any help anyone can give me.
 
Is there a way to do this in a query? I'm having the same
problem as Ray is having, but I'm not working with forms
or reports. I need to add an Age field to a table. Any
help on this would be great. Thanks!
-----Original Message-----
Sample with explanation at:
http://allenbrowne.com/func-08.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I'm trying to calculate a person's age in a query as of Now
(). The following is my query.

Age: Format(Date(),"yyyy")-(Format([Birthdate],"yyyy"))

I tried Steves Schapel's Dec 15 reply to Al but I get the
same results I get with the above statement. The problem
is when I run the query today (Dec 16) and the person's
birthday is Dec 30, 1943 I get his age as 60 instead of
59. I understand why my query gives the results I get but
I don't know how to modify it to give the wanted results.
Thanks for any help anyone can give me.


.
 
Sure. You can create a calculated field in a query, using the Age()
function.

Just type this into a fresh column of the query design grid (Field row):
Age: Age([DOB])

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Jamie said:
Is there a way to do this in a query? I'm having the same
problem as Ray is having, but I'm not working with forms
or reports. I need to add an Age field to a table. Any
help on this would be great. Thanks!
-----Original Message-----
Sample with explanation at:
http://allenbrowne.com/func-08.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I'm trying to calculate a person's age in a query as of Now
(). The following is my query.

Age: Format(Date(),"yyyy")-(Format([Birthdate],"yyyy"))

I tried Steves Schapel's Dec 15 reply to Al but I get the
same results I get with the above statement. The problem
is when I run the query today (Dec 16) and the person's
birthday is Dec 30, 1943 I get his age as 60 instead of
59. I understand why my query gives the results I get but
I don't know how to modify it to give the wanted results.
Thanks for any help anyone can give me.


.
 
Assuming the Date of Birth field is called DOB cut the following and paste
in a Field in the QBE grid:

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

(I think I found this on Dev Avish's page - but after a few crashes I have
lost the source)

HTH
Grant



Jamie said:
Is there a way to do this in a query? I'm having the same
problem as Ray is having, but I'm not working with forms
or reports. I need to add an Age field to a table. Any
help on this would be great. Thanks!
-----Original Message-----
Sample with explanation at:
http://allenbrowne.com/func-08.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I'm trying to calculate a person's age in a query as of Now
(). The following is my query.

Age: Format(Date(),"yyyy")-(Format([Birthdate],"yyyy"))

I tried Steves Schapel's Dec 15 reply to Al but I get the
same results I get with the above statement. The problem
is when I run the query today (Dec 16) and the person's
birthday is Dec 30, 1943 I get his age as 60 instead of
59. I understand why my query gives the results I get but
I don't know how to modify it to give the wanted results.
Thanks for any help anyone can give me.


.
 
Back
Top