DateDiff

Excuse my ignorance, but I dont understand Strings:confused:Please explain?
Data is of Different types.

eg Number is 0,1,2,3,etc
Date is 03/03/2000 etc

A string is anything or should I say a combination of every thing.

eg. 12WWee768 65fg

2012 can be either a Number, a Year or a string depending on the way it has been formated.

You used [Year] which could be the Name of a field which would be a string.

Hope this helps.
 
I am using 2003 and the this coding works for me,

=age([DOB]) & "yrs" & " " & AgeMonths([DOB]) & "months"
Actually your code, as posted, does nothing except pop an error! That's because Age() and AgeMonths() are not native Access Functions. Presumably they are Custom Functions, but since we don't have the code for them we can't really tell if they're accurate or not.

rodmc's hack

Code:
=Round((Date()-[DoB])/365)

has been put forth a number of times before, and if I remember correctly, it is usually accurate, except under certain conditions involving a February birthday and Leap Years, if I remember correctly! :rolleyes: Unless you're dealing with a critical legal scenario, such as carding someone at a liquor store or awarding an inheritance upon turning 21 years of age, I suspect it works just fine! :D

Linq ;0)>
 
Further to my age answer , basic error it is a Function as follows:

Function Age(varBirthDate As Variant) As Integer
Dim varAge As Variant

If IsNull(varBirthDate) Then Age = 0: Exit Function

varAge = DateDiff("yyyy", varBirthDate, Now)
If date < DateSerial(year(Now), Month(varBirthDate), _
Day(varBirthDate)) Then
varAge = varAge - 1
End If
Age = CInt(varAge)
End Function
 

Users who are viewing this thread

Back
Top Bottom