PC Review


Reply
Thread Tools Rate Thread

Calculating a person's age

 
 
Rich Stone
Guest
Posts: n/a
 
      7th Jan 2010
I have a database where I enter the person's date of birth. The users of the
database want to be able to see the age of the person as of the day they are
viewing. I thought this would be simple and entered the following into a
query to provide an age field for the form:

DateDiff("yyyy",[PatientDOB],Now())

However, it appears that this is only accurate some of the time and with the
new year I have noticed that this is more prominent. Is there a better
formula for working this out? It doesn't necessarily have to be in the query
as it can be calculated in a field that updates when the form is refreshed.


 
Reply With Quote
 
 
 
 
XPS350
Guest
Posts: n/a
 
      7th Jan 2010
On 7 jan, 11:54, Rich Stone <RichSt...@discussions.microsoft.com>
wrote:
> I have a database where I enter the person's date of birth. The users of the
> database want to be able to see the age of the person as of the day they are
> viewing. I thought this would be simple and entered the following into a
> query to provide an age field for the form:
>
> DateDiff("yyyy",[PatientDOB],Now())
>
> However, it appears that this is only accurate some of the time and with the
> new year I have noticed that this is more prominent. Is there a better
> formula for working this out? It doesn't necessarily have to be in the query
> as it can be calculated in a field that updates when the form is refreshed.


You could build your own function and use it in the query. The
function looks like:

Function Age(DateOfBirth As Date) As Byte
If Format(DateOfBirth, "mmdd") > Format(Date, "mmdd") Then
Age = DateDiff("yyyy", DateOfBirth, Date) - 1
Else
Age = DateDiff("yyyy", DateOfBirth, Date)
End If
End Function


Groeten,

Peter
http://access.xps350.com
 
Reply With Quote
 
Rich Stone
Guest
Posts: n/a
 
      7th Jan 2010
Thanks for your help. Works perfectly!

"BruceM via AccessMonster.com" wrote:

> Here is a link to a few different methods:
>
> http://www.mvps.org/access/datetime/date0001.htm
>
> One of the methods is similar to what was posted, except uses the Year
> function rather than formatted values. Another method shows how to get years,
> months, and days, if you want that level of detail.
>
> Rich Stone wrote:
> >I have a database where I enter the person's date of birth. The users of the
> >database want to be able to see the age of the person as of the day they are
> >viewing. I thought this would be simple and entered the following into a
> >query to provide an age field for the form:
> >
> >DateDiff("yyyy",[PatientDOB],Now())
> >
> >However, it appears that this is only accurate some of the time and with the
> >new year I have noticed that this is more prominent. Is there a better
> >formula for working this out? It doesn't necessarily have to be in the query
> >as it can be calculated in a field that updates when the form is refreshed.

>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...ccess/201001/1
>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating person's age referring to absolute cell PH@tic Microsoft Dot NET 1 18th Jul 2008 05:51 PM
Calculating age when person born before 1900 =?Utf-8?B?c2l0cyBpbiB0aGUgc3RhbmRz?= Microsoft Excel Worksheet Functions 1 19th Oct 2006 07:32 AM
calculating a person's age based on a certain day based on date of birth Kathie G via AccessMonster.com Microsoft Access Reports 1 24th Feb 2006 08:16 PM
Calculating Age of person on admission date Alan Microsoft Excel Misc 10 8th Oct 2005 06:30 AM
Re: Calculating a person's age in Outlook Milly Staples [MVP - Outlook] Microsoft Outlook 0 24th Jul 2003 03:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:53 AM.