|
* 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.
- 액세스 버전(95,97,2000,xp,2003,2007):
* 아래줄에 질문을 작성하세요 >>
묻고답하기에서 근무년수를 검색해보니 근무년과 월까지만 구해지는 모듈은 있는데 일까지 구할수 있는지 있으면 알려주시면 감사하겠습니다.
Public Function LenOFSvc(고용일 As Date, Optional 퇴직일 As Variant) As String
Dim totalm As Integer
Dim m As Integer
Dim y As Integer
Dim xx As Date
If IsNull(퇴직일) Then
xx = Date
Else: xx = 퇴직일
End If
If Day(고용일) > Day(xx) Then
totalm = DateDiff("m", 고용일, xx) - 1
Else
totalm = DateDiff("m", 고용일, xx)
End If
y = totalm \ 12
m = totalm Mod 12
LenOFSvc = y & "년" & m & "개월"
End Function
==============[대왕초보님 글에 대한 답변입니다]==============
Dim totalm As Integer
Dim d As String
Dim m As String
Dim y As String
Dim xx As Date
If IsNull(퇴직일) Then
xx = Date
Else
xx = 퇴직일
End If
If Day(고용일) > Day(xx) Then
totalm = DateDiff("m", 고용일, xx) - 1
Else
totalm = DateDiff("m", 고용일, xx)
End If
y = Format(totalm \ 12, "00")
m = Format(totalm Mod 12, "00")
d = Format(xx - DateSerial(Year(xx), Month(xx), 1), "00")
LenOFSvc = y & "년 " & m & "개월 " & d & "일" |
|