Avatar of jph826
jph826
 asked on

Age as of Jan 1 current year

I need a formula to calculate an employee's age as of January 1 of the current year.  

I need another formula to calculate an employee's age as of January 1 of the upcoming year.  

Any assistance would be greatly appreciated.  Thanks
Crystal Reports

Avatar of undefined
Last Comment
jph826

8/22/2022 - Mon
Ido Millet

DateVar BirthDate := {Your_BirthDate_Field};
DateVar Start_year := Date(Year(currentdate), 01, 01);

if (Month(Start_year) * 100) + Day (Start_year) >= (Month(BirthDate) *100) + Day (BirthDate) 
then Year(Start_year) - Year(BirthDate) 
else Year(Start_year) - Year(BirthDate) -1;

Open in new window


And the age at the start of next year is simply the above + 1.
peter57r

What about those born on 1 Jan?

If someone was born on say , 1 Jan 1983 do you want the answer for the current year to be 30 or 29?
jph826

ASKER
Good question.  I would want their age on January 1, current year, or in your example, 30.  I'm having trouble getting the suggested formula to work.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Ido Millet

You should change {Your_BirthDate_Field} to YOUR birthdate column.

If that was not the issue, please explain what type of "problem" you are referring to.
jph826

ASKER
Thanks IdoMillet.  It hi-lights MY birthdate field, {PAEMPLOYEE.BIRTHDATE}, and says a date is required here.  If I change it to .... Date {PAEMPLOYEE.BIRTHDATE} it hi-lights everything after Date and returns "the remaining text does not appear to be part of the formula.

{PAEMPLOYEE.BIRTHDATE} is a DateTime field.
Ido Millet

What is the data type of {PAEMPLOYEE.BIRTHDATE} ?

Please copy and paste the text of your formula.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Ido Millet

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jph826

ASKER
That worked, thanks for your assistance!