Rabu, 20 Maret 2024

Re: [MSAccessProfessionals] Date Calculation not giving corrct age

I would use Doug Steele's better date diff function found at https://www.accessmvp.com/DJSteele/Diff2Dates.html

Duane


From: LOU(at home) <lou@ix.net.au>

 

Hello lovely people! It's a long time since I've been on here but I need your help.
I have this code to calculate and display a person's age when they passed away but it's giving me the wrong age, it adds one year to their age!

I read somewhere that it could have something to with Leap Years, but my old brain can't work it out.
Your help would be appreciated.
Thank you.

The person was born on: 4th Oct. 1923
and passed away on: 25th May 2021
Her age should have been 97 years and 7 months
NOT 98 years and 7 months
=DateDiff("yyyy",Nz([Death_Ann],Date()),Date())+(Date()<DateSerial(Year(Date()),Month(Nz([Death_Ann],Date())),Day(Nz([Death_Ann],Date())))) & " Years, " & (DateDiff("m",Nz([Death_Ann],Date()),Date())) Mod 12 & " Months Ago"


_.

Tidak ada komentar:

Posting Komentar