Frink1234 Posted April 23, 2005 Posted April 23, 2005 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?
LaRetta Posted April 23, 2005 Posted April 23, 2005 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
Frink1234 Posted April 24, 2005 Author Posted April 24, 2005 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
LaRetta Posted April 24, 2005 Posted April 24, 2005 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
Frink1234 Posted April 24, 2005 Author Posted April 24, 2005 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.
idgely Posted April 28, 2005 Posted April 28, 2005 thank you so much for this.... that's all she has to say
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now