subtracting 2 dates to calculate age; format as years days

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,
 
J

John W. Vinson

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
 
D

Daniel Collison

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
 
J

John W. Vinson

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.
 
D

Daniel Collison

Thanks...i was able to bring into module, save and then use the diff2dates
function without a problem. Appreciate the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top