|
给你做个查询函数计算法,其他的你自已去相想吧
SELECT 表1.*, IIf(Format([入职日期],"yyyy-mm-dd")>=Format(Date(),"yyyy-mm-dd"),Year([入职日期])-Year(Date())-IIf(Format([入职日期],"mm-dd")<Format(Date(),"mm-dd"),1,0) & "年" & Month([入职日期])-Month(Date())+IIf(Format([入职日期],"mm-dd")<Format(Date(),"mm-dd"),12,0) & "月" & IIf(Day([入职日期])>=Day(Date()),Day([入职日期])-Day(Date()),DateDiff("d",DateSerial(Year(DateSerial(Year([入职日期]),Month([入职日期]),1)-1),Month(DateSerial(Year([入职日期]),Month([入职日期]),1)-1),Day(Date())),[入职日期])) & "日",Year(Date())-Year([入职日期])-IIf(Format(Date(),"mm-dd")<Format([入职日期],"mm-dd"),1,0) & "年" & Month(Date())-Month([入职日期])+IIf(Format(Date(),"mm-dd")<Format([入职日期],"mm-dd"),12,0) & "月" & IIf(Day(Date())>=Day([入职日期]),Day(Date())-Day([入职日期]),DateDiff("d",DateSerial(Year(DateSerial(Year(Date()),Month(Date()),1)-1),Month(DateSerial(Year(Date()),Month(Date()),1)-1),Day([入职日期])),Date())) & "日") AS 在职时间
FROM 表1;
|
|