Jump to content

getting the accurate number of days


This topic is 5646 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello

I have a calculation which determines the age of a person.

it is

Year(Get(CurrentDate)) - Year(dateofbirth)

This however returns 56 years. The original dateofbirth entry was

05/29/1950

I wouldlike to find a way or a formula to determine the exact number of days this person has been alive and I need help with this.

Thanks very very much

Dave

Link to comment
Share on other sites

This topic comes up all of the time. If you did a search for Age, Birthday Calculation, etc. you should see a bunch of treads on this.

Here is a calculation:

GetAsNumber(Year(Get(CurrentDate)) -

Year(dateofbirth) - Case(Get(CurrentDate) <

Date(Month(dateofbirth); Day(dateofbirth); Year(Get(CurrentDate))); 1; 0)) & " Years, "

&

GetAsNumber(Mod(Month(Get(CurrentDate)) -

Month(dateofbirth) + 12 - Case(Day(Get(CurrentDate)) <

Day(dateofbirth); 1; 0); 12)) & " Months, "

&

GetAsNumber(Day(Get(CurrentDate)) -

Day(dateofbirth) + Case(Day(Get(CurrentDate)) >=

Day(dateofbirth); 0; Day(Get(CurrentDate) -

Day(Get(CurrentDate))) <

Day(dateofbirth); Day(dateofbirth); Day(Get(CurrentDate) -

Day(Get(CurrentDate))))) & " Days"

HTH

Lee

Link to comment
Share on other sites

And I'll add to it. The issue is dropping one year if the current year's birthday hasn't happened yet. Since you just want number of years, try:

Let (

thisBday = Date ( Month ( dateofbirth ) ; Day ( dateofbirth ) ; Year ( Get (CurrentDate) ) ) ;

Year ( Get ( CurrentDate) ) - Year ( dateofbirth ) - ( thisBday > Get ( CurrentDate ) )

)

Corrected less than to greater than ... :blush2: Freudian slip. And I should mention this is result of number and needs to be UNSTORED. The GetAsNumber is not required because FM adds dates just fine - they ARE numbers. I believe you threw Kent off because you contradicted yourself - first wanting years but then saying exact number of DAYS. If so, a number result with: Get ( CurrentDate ) - dateofbirth will give you their total days.

Link to comment
Share on other sites

This topic is 5646 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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