Quote:
Originally Posted by barand
Something like
Code:
SELECT name, (TO_DAYS(CURDATE()) - TO_DAYS(start_date))/365 AS service_years FROM s_emp
ORDER BY service_years DESC
|
The above code does not take into account leap years. You will want to use the
DateDiff function or the
DateAdd function. The DateAdd function allows for you to pass an "interval" in as a parameter. This will allow the function to perform a subtraction routine.
Regards,
Chris Danielson