View Single Post
  #4 (permalink)  
Old 2007-11-30, 01:12 AM
danielsonchris danielsonchris is offline
Junior Member
 
Join Date: Nov 2007
Location: San Diego, CA
Posts: 2
danielsonchris is on a distinguished road
Default

Quote:
Originally Posted by barand View Post
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
__________________
MaxPowerSoft, LLC

Last edited by danielsonchris; 2007-11-30 at 01:16 AM. Reason: End user wanted result in years not days.
Reply With Quote