Re: Calculating Age
From: Graham R Seach (gseach_at_NOSPAMpacificdb.com.au)
Date: 08/06/04
- Next message: TC: "Re: Implementing a Save, Delete or Cancel MsgBox"
- Previous message: Billy Reid: "Access 97 - rows repeat when entering"
- In reply to: Mark: "Re: Calculating Age"
- Next in thread: Julie Nicole: "Re: Calculating Age"
- Reply: Julie Nicole: "Re: Calculating Age"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 6 Aug 2004 14:19:29 +1000
When trying to calculate anniversaries, DateDiff is prone to errors, simply
because of the way it works. Unless you take into account the way DateDiff
works, you can end up being a year off.
Perhaps the following functions can help:
http://www.pacificdb.com.au/MVP/Code/Age1.htm
http://www.pacificdb.com.au/MVP/Code/Age2.htm
http://www.pacificdb.com.au/MVP/Code/Diff2Dates.htm
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
"Mark" <anonymous@discussions.microsoft.com> wrote in message
news:06bb01c47add$e1004970$a301280a@phx.gbl...
> This is quite a crude way of calculating an age. If you
> select the Access Help menu and type Datediff there may be
> an example and description of how to use it. It's not
> strictly code but a built-in function of Access.
>
> Just a word of warning - The DateDiff function is best
> used to show the number of days between two dates. I
> didn't realise you were using it for such a specific task.
> If you enter a date of birth of 01/10/2003 you will see
> the answer is 1 year (obviously not correct) because the
> calculation uses a type of rounding.
>
> To calculate the number of months, change the formula to
>
> =DateDiff("m",[DOB],Now())
>
>
> To calculate the number of days, change it to
>
> =DateDiff("y",[DOB],Now())
>
>
> It may be better to work with months rather than years for
> your requirements.
>
> Hope this helps
>
>
>
>
> >-----Original Message-----
> >Great!!! Thanks Mark,
> >
> >Is it possible to take it one step further where if say
> the DOB i13-06-03
> >that the forula in the age field would bring up 1/1 for 1
> year and 1 month.
> >I didnt realise it had to be exact to the year and
> month. Its for show cats
> >and its inmortant that its calculated to the month as
> this depends on what
> >class they enter depending on their aage by year and
> month.
> >
> >thanks
> >Julie
> >
> >
> >"Mark" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:062b01c47abf$ca5dbea0$a501280a@phx.gbl...
> >> In the field you want to calculate the Age, bring up the
> >> field properties, select the data tab and in the Control
> >> Source enter
> >>
> >> =DateDiff("yyyy",[DOB],Now())
> >>
> >> Where [DOB] is your date of birth field
> >>
> >>
> >> >-----Original Message-----
> >> >If I have the Date of Birth in a field, what expresion
> >> can I use in another
> >> >field, say AGE field, that would calculate the actual
> age
> >> automatically?
> >> >
> >> >Like DOB field has 29/06/66 in it so Age field becomes
> 38
> >> calculated
> >> >automatically when DOB is entered.
> >> >
> >> >thanks
> >> >Julie
> >> >
> >> >
> >> >.
> >> >
> >
> >
> >.
> >
- Next message: TC: "Re: Implementing a Save, Delete or Cancel MsgBox"
- Previous message: Billy Reid: "Access 97 - rows repeat when entering"
- In reply to: Mark: "Re: Calculating Age"
- Next in thread: Julie Nicole: "Re: Calculating Age"
- Reply: Julie Nicole: "Re: Calculating Age"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|