subtracting 2 dates to calculate age; format as years days

  • Thread starter Thread starter Daniel Collison
  • Start date Start date
D

Daniel Collison

I have created a query which includes a calculated fields using the following
calculation:

Age: DateDiff("yyyy",[DOB],#7/1/2007#)

The result correctly shows the age in years. However, I would like to show
age as years and days, i.e "16 024", "16 360", etc.

Any suggestions?

Thanks,
 
I have created a query which includes a calculated fields using the following
calculation:

Age: DateDiff("yyyy",[DOB],#7/1/2007#)

The result correctly shows the age in years. However, I would like to show
age as years and days, i.e "16 024", "16 360", etc.

Any suggestions?

Thanks,

Try Doug Steele and Graham Seach's Diff2Dates function, which is DateDiff
unleashed:

http://www.accessmvp.com/djsteele/Diff2Dates.html
 
John:

Thanks for the quick turnaround. I'm not a programmer, so I am unclear how
I would incorporate the new Diff2Dates function into access. Is this easy to
do? Or is there existing Access formatting that I can use in the query?

Thanks,


John W. Vinson said:
I have created a query which includes a calculated fields using the following
calculation:

Age: DateDiff("yyyy",[DOB],#7/1/2007#)

The result correctly shows the age in years. However, I would like to show
age as years and days, i.e "16 024", "16 360", etc.

Any suggestions?

Thanks,

Try Doug Steele and Graham Seach's Diff2Dates function, which is DateDiff
unleashed:

http://www.accessmvp.com/djsteele/Diff2Dates.html
 
John:

Thanks for the quick turnaround. I'm not a programmer, so I am unclear how
I would incorporate the new Diff2Dates function into access. Is this easy to

Simply copy and paste the function from the webpage into a new Module; save
the module with any name OTHER than Diff2Dates (I'd use basDates perhaps);
click Debug... Compile and save.

Then in your Query just call Diff2Dates in accordance with its comments (in
this case use "yd" as the interval) instead of calling DateDiff.
do? Or is there existing Access formatting that I can use in the query?

This is not a formatting issue. You're actually doing a calculation.
 
Thanks...i was able to bring into module, save and then use the diff2dates
function without a problem. Appreciate the help.
 
Back
Top