I have a field named Dob, i want to creat query with the age in years, months, days. can you tell me how to write the expression for diff2date. Or direct me to a web site that has it.
I have a field named Dob, i want to creat query with the age in years, months, days. can you tell me how to write the expression for diff2date. Or direct me to a web site that has it.
There are many sites that have ways to calculate ages. Here is one site:
http://access.mvps.org/access/datetime/date0001.htm
Google: DateDiff
http://msdn.microsoft.com/en-us/libr...9(SQL.80).aspx
Problem with DateDiff is rounding. The results you get might not be quite as you expect because you want age down to the day. That is why ssansu suggested that link. What that example shows is a custom public procedure that can be called in an expression just as you would the intrinsic DateDiff. It is shown as a Sub but easy to modify to a Function.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
if i could get the syntax for the expression please, access 2010 Query
i have a field called "DOB" the date is a short date.
what i would like to see for the end results is.
Example would be, 39 years 11 months 27 days this would be called the "Age" field
hope someone can help
thanks to all
You need to build the Function procedure in a general code module. You would need to add a line in the function that would concatenate the date parts into one string that would be returned by the function. Then you can call the procedure from anywhere - VBA or textbox or query. In the ControlSource for a textbox would be: = CalcAge(DOB, Date())
If you are not familiar with writing code, check out some tutorials. Google: VBA Access custom function
Here is one http://www.helium.com/items/220687-h...crosoft-access
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.