# Thread: DateDif (2000)

1. ## DateDif (2000)

=DateDiff("Y",[Dateofbirth],[DateofDeath])
The above gives me the correct answer but in total days between, whereas in Excel "Y" gives the answer in Years and throws away the days, or with "D" instead of "Y" I get elapsed days. If I change the first formula in Access to "D" the D becomes d and the answer is the same as Y, M doeesn't make any difference either.
Can someone please tell me the correct formula

2. ## Re: DateDif (2000)

Click in DateDiff (in the Visual Basic Editor) and press F1 to get online help. You'll see that you need to use "yyyy" to get years.

Here is a VBA function to calculate someone's age in years, from an example by Microsoft:

Function Age(Bdate, DateToday) As Integer
' Returns the Age in years between 2 dates
' Doesn't handle negative date ranges i.e. Bdate > DateToday
Age = Year(DateToday) - Year(Bdate)
If Month(DateToday) < Month(Bdate) Or _
(Month(DateToday) = Month(Bdate) And Day(DateToday) < Day(Bdate)) Then
Age = Age - 1
End If
End Function

3. ## Re: DateDif (2000)

Thank you very much, Hans. The age function is more suitable for my purposes than the DateDiff anyway.
It is remarkable how few, of those to whom it would be useful, actually know about or use Woody's lounge.
Many thanks for your help

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•