Jump to content

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

Recommended Posts

Posted

I'm using the wonderfully simple age calc found elsewhere on this board by one of you brilliant calc-heads:

Year(Get(CurrentDate)) - Year(Date of Birth) - (Get(CurrentDate)< Date(Month(Date of Birth); Day(Date of Birth); Year(Get(CurrentDate))))

The only problem is that I need it to show the age in years and months. Can I add a simple line to the above calc to get this to work?

Posted

Hi Frink1234,

Okay I'll bite because I just can't help myself. I adore figuring date calculations even though they can always be improved upon ...

Year(Get(CurrentDate)) - Year(Date of Birth) -

If(Get(CurrentDate) < Date(Month(Date of Birth); Day(Date of Birth); Year(Get(CurrentDate))); 1; 0) & " Years, " & Mod(Month(Get(CurrentDate)) - Month(Date of Birth) + 12 -

If(Day(Get(CurrentDate)) < Day(Date of Birth); 1; 0); 12) & " Months"

LaRetta wink.gif

Posted

An excellent and elegant solution LaRetta!

It took me a minute to realize that I had to change "calculation result is TEXT" from the original equation where "calculation result is NUMBER".

Thank you!

- Frink wink.gif

Posted

Apologies for not mentioning the calculation result should be text. I try not to take things for granted, ie, that it would be understood to be text but sometimes I slip. crazy.gif

I'm usually accused of saying too much not too little. wink.gif

BTW, this calculation principle was learned from CobaltSky a few years back, I believe. But I've found myself reviewing all calculations and converting many of them using Let() now that I'm *grokking* it. There are many times that Let() can decrease evaluations particularly where the same test (or a portion) must be repeated. It also displays clearer logic and makes calculations easier to vizualize while I write them (thanks Comment!).

But alas in this case, I see no way to use Let() which would benefit the calculation.

LaRetta

Posted

No apologies needed. After all, it's good for me to have to figure some things out for myself, that's how I learn. I hope someday I will grok. wink.gif

This topic is 7256 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
×
×
  • Create New...

Important Information

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