April 23, 200520 yr 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?
April 23, 200520 yr 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
April 24, 200520 yr Author 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
April 24, 200520 yr 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. I'm usually accused of saying too much not too little. 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
April 24, 200520 yr Author 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.
Create an account or sign in to comment