我有以下代码来计算员工的服务时间:
CONCAT(
TIMESTAMPDIFF(YEAR, hiredate, NOW())," years, ",
TIMESTAMPDIFF(MONTH, hiredate, NOW()) MOD 12," months, ",
TIMESTAMPDIFF(DAY, hiredate, NOW()) MOD 365," days"
) AS EmployLengthActive
大部分时间他们工作正常,但今天我发现他们已经关闭了? 例如:
hiredate是MySQL" DateTime类型(默认为00:00:00)
有没有更好的方法来计算年/月/日的时间长度?