Chintsapete
Registered User.
- Local time
- Tomorrow, 00:00
- Joined
- Jun 15, 2012
- Messages
- 137
Hi all
I used below function for a couple of year and I thought it was working. Now I noticed that it's not working to my requirements.
The problem is that if an employee starts working in November it's year 0 until January and then it becomes year 1, instead of becoming year 1 in November following year. Is there a way to change the function below that only after 12 months employment it becomes 1 year etc.
Any help would be appreciated.
I used below function for a couple of year and I thought it was working. Now I noticed that it's not working to my requirements.
The problem is that if an employee starts working in November it's year 0 until January and then it becomes year 1, instead of becoming year 1 in November following year. Is there a way to change the function below that only after 12 months employment it becomes 1 year etc.
Any help would be appreciated.
Code:
Public Function fnYearsEmployed(DateOfEngagment _
, DateOfTermination)
Dim YearsEmployed As Integer
Dim EndDate
If IsNull(DateOfTermination) Then
EndDate = Date
Else
EndDate = DateOfTermination
End If
YearsEmployed = Nz(Int((DateDiff("yyyy", DateOfEngagment, EndDate))))
fnYearsEmployed = YearsEmployed
End Function