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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you subtract a hire date from the current date

Status
Not open for further replies.

ginabops

IS-IT--Management
Apr 1, 2004
1
US
I need to do a report for years of service. The field for hiredate is called arvdate and it shows on the report in the mm/dd/yyyy format. How do I create another column that gives the years of service.
 
From kenhamady.com, try:

WhileReadingRecords;
DateVar Birth:= {ages.Birth}; // Replace this with your field for Date Of Birth
DateVar Ann := {ages.DateAnn}; // Replace this with CurrentDate to get their age as of the time of the report
//or the date field of an event to get their age as of the time of that event.
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1

Note that just using the year(currentdate) - year{table.date}) will not be correct, nor will the datediff function.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top