# How to identify anniversaries next month?

CRV 11 - I have an anniversary report that runs on the 20th of every month showing anniversaries in the upcoming month (regardless of day) .
The December 20th report showed two employees; one with a hire date of 1/3/2011 (result was 6 yrs of service) and one with a hire date of 1/28/2013 (result was 4 yrs of service).  BOTH results are short one year and should be 7 and 5.  The formula I'm using is Year (currentdate) - Year({EMPLOYEE.DATE_HIRED}).  Any advice would be appreciated.
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Your formula works for every month except the December run because of crossing the year boundary.

I can think of 2 solutions. The easy solution is to test for current month = 12 then add 1

``````If Month(CurrentDate) = 12 then
Year (currentdate) - Year({EMPLOYEE.DATE_HIRED} + 1
Else
Year (currentdate) - Year({EMPLOYEE.DATE_HIRED}
``````

The other will work depending on how you are selecting the date range.  If you are prompting for the date range you could use the date value from the parameter instead of current date.

Year({?StarDate}) - Year({EMPLOYEE.DATE_HIRED

mlmcc
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Professor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
"The problem with calculating age is that it is calculated as an integer, and always rounded down..."
0
Author Commented:
Thank you, that worked.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.