select day_,jday_, startdateofemp,mms,format(floor((mms-dayadj)/12),0) as years , mod(mms-dayadj,12) as mths ,
alias,surname from (SELECT *,
(year(curdate())*12+month(curdate()))-(year(startdateofemp)*12+month(startdateofemp))
as mms,
case when day(curdate())>=day(startdateofemp) then 0 else 1 end as dayadj,
day(curdate()) day_, day(startdateofemp) jday_
from employee where status='A') x;
沒有留言:
張貼留言