Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Years

Status
Not open for further replies.

TEM3

Technical User
Dec 6, 2004
324
US
Using Crystal Reports 8.5:

I want to count the number of years and fractional remaining time between two dates.

Lets say I have a table field {Date_Of_Hire}. If {Date_Of_Hire} = date("06/07/1971"), I know that currentdate - {Date_Of_Hire} = 36 years and 88 days or (the value I want), 36.24 years.

Is there a function in CR 8.5 that will give me the number of whole years and a decimal remainer between two dates? If not, does anyone have a formula that will do the job??
 
This is close:

datediff("d",{YourDate},currentdate)/365

A year is actually 365.25 days, hence the leap year every 4 years. Will this suffice?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If the phone doesn't ring, it's me".....Jimmy Buffet
 
I'll try it tomorrow. Thanks. The purpose of this particular formula is to figure retirement percentage amounts, which is calculated as (years_of_service/55) * current salary.
 
I'd do it by stages. First, get the number of whole years between hire and the retirement date. DateDiff("y", {hire.date}, {retirement date}. Then add this number of years to the hire date, using DateAdd. Finally use DateDiff("d", to find the number of days.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top