Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Show Age in Days Months and Years

Featured Replies

I know this is covering old ground and I've checked out other posts, but still can't figure it out. I need to calculate someones age in days months and years. I have a date of birth (DOB) and an Age field. If I just calculate Age something like

Get(CurrentDate) - DOB

everything is fine as long as I store the result as a number. If I store as a date, the year part of the calcuation gets screwed up. Anything less than 12 months old shows 1 in the year. How do I get this to work correctly?

First let me say that this sort of a meaningless calculation, a month can be 28 to 31 long. A year can be 365 or 366 days.

I have not found a calculation that I trust. Most of them fail when the birthday is the 31st and the current month has 30 or less days.

The following is the best I have seen, it was developed by Jason L. DeLooze:

Year = Case(

not IsEmpty(Test_Date) and not IsEmpty(Birthday) and (Test_Date >= Birthday) ;

Year(Test_Date) - Year(Birthday) - ( Test_Date < Date( Month(Birthday) ; Day(Birthday) ; Year(Test_Date) ) )

)

Month = Case(

not IsEmpty(Test_Date) and not IsEmpty(Birthday) and (Test_Date >= Birthday) ;

Mod( Month(Test_Date) - Month(Birthday) + 12 - ( Day(Test_Date) < Day(Birthday) ) ; 12 )

)

Day = Case(

not IsEmpty(Test_Date) and not IsEmpty(Birthday) and (Test_Date >= Birthday) ;

Case(

Day(Test_Date) >= Day(Birthday) ; Day(Test_Date) - Day(Birthday) ;

Date( Month(Birthday) + 1 ; 1 ; Year(Birthday) ) - Birthday + Day(Test_Date) - 1

)

)

  • Author

Thanks RalphL. I understand when you say it's meaningless, but everything is relative. My user just wants something that is roughly correct to read out loud. Any maths work will be done by other methods.

The formulas you gave me worked perfectly, thanks a lot.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.