Forum Discussion
This formula was for Age, but I changed it to be used for completed years of service.
var date EST = [Empl Svc Dt];
Year(Today())-Year($EST)
-
If(
Month(Today())<Month($EST)
or
(Month(Today())=Month($EST) and Day(Today())<Day($EST)),1,0)
- StephanieHarris9 years agoQrew Assistant CaptainI am trying to do this however I don't need to know their actual years of service as today, only as of the date an incident was reported. Basically I need to know the years between Hire Date and Date Reported.
- QuickBaseCoachD9 years agoQrew CaptainTry this
 var date HireDate = [My Hire Date field];
 var date IncidentDate = [My Incident Field];
 Year($IncidentDate -Year($HireDate)
 -
 If(
 Month($IncidentDateToday()) < Month($HireDate$EST)
 or
 (Month($IncidentDate) = Month($IncidentDate) and Day($HireDate <Day($IncidentDate),1,0)
- StephanieHarris9 years agoQrew Assistant CaptainIt's giving me a syntax error
- QuickBaseCoachD9 years agoQrew CaptainCorrected:
 var date HireDate = [My Hire Date field];
 var date IncidentDate = [My Incident Field];
 Year($IncidentDate -Year($HireDate)
 -
 If(
 Month($IncidentDate) < Month($HireDate)
 or
 (Month($IncidentDate) = Month($IncidentDate) and Day($HireDate <Day($IncidentDate),1,0)
- StephanieHarris9 years agoQrew Assistant CaptainWorked with a slight adjustment: var date HireDate = [Employee Adjusted Service Date]; var date IncidentDate = [Date Reported]; Year($IncidentDate) -Year($HireDate) - If(Month($IncidentDate) < Month($HireDate) or Month($IncidentDate) = Month($IncidentDate) and Day($HireDate) <Day($IncidentDate),1,0) Thanks! 
- QuickBaseCoachD9 years agoQrew CaptainOK, thx for letting me know.
- StephanieHarris9 years agoQrew Assistant CaptainI just noticed this is giving me a negative 1, I expected this for when the Date Reported was before the Employee Adjusted Service Date, however this is also happening in instances such as Date Reported = 5/23/17 and Employee Adjusted Hire Date = 1/15/2017
- QuickBaseCoachD9 years agoQrew CaptainYou can put a floor of zero on the result.var date HireDate = [Employee Adjusted Service Date]; var date IncidentDate = [Date Reported]; var number RawCalc = Year($IncidentDate) -Year($HireDate) - If(Month($IncidentDate) < Month($HireDate) or 
 Month($IncidentDate) = Month($IncidentDate) and Day($HireDate) <Day($IncidentDate),1,0);
 Max(0, $RawCalc)
- StephanieHarris9 years agoQrew Assistant CaptainThis field is currently Formula Numeric, I'd like to add that if [Employee Adjusted Service Date] is Null this field reflects as "Unknown". I tried the following but it doesn't work. Any suggestions?var date HireDate = [Employee Adjusted Service Date]; var date IncidentDate = [Date Reported]; var number RawCalc = Year($IncidentDate) -Year($HireDate) - If(IsNull([Employee Adjusted Service Date]), "Unknown", If(Month($IncidentDate) < Month($HireDate) or Month($IncidentDate) = Month($IncidentDate) and Day($HireDate) <Day($IncidentDate),1,0)); 
 Max(0, $RawCalc)