The following 2 functions can be used to calcualte the (respective) FIRST and LAST date of the month for ANY date that is passed to it ..... please note that the optional parameters in BOTH functions were added to my original functions for specific purposes on the current application that I have just completed, and in the main (and for you) they can be ignored.
CODE
Function FirstOfMonth(InputDate As Variant, _
Optional ReturnAsNumeric As Boolean = False, _
Optional ReversedOrder As Boolean = False) _
As Variant
' Return a date that is the first day of the month of the date passed
Dim d As Integer, m As Integer, Y As Integer
If IsNull(InputDate) Then
FirstOfMonth = Null
Else
d = 1
m = Month(InputDate)
Y = Year(InputDate)
If ReturnAsNumeric = False _
And ReversedOrder = False Then
FirstOfMonth = DateSerial(Y, m, d)
Else
If ReturnAsNumeric = False Then
FirstOfMonth = Y & "/" & Format(m, "00") & "/" & Format(d, "00")
Else
If ReversedOrder = False Then
FirstOfMonth = Format(d, "00") & Format(m, "00") & Y
Else
FirstOfMonth = Y & Format(m, "00") & Format(d, "00")
End If
End If
End If
End If
End Function
'
'
Function LastOfMonth(InputDate As Variant, _
Optional ReturnAsNumeric As Boolean = False, _
Optional ReversedOrder As Boolean = False) _
As Variant
' Return a date that is the last day of the month of the date passed
Dim d As Integer, m As Integer, Y As Integer
Dim WorkDate As Date
If IsNull(InputDate) Then
LastOfMonth = Null
Else
d = Day(InputDate)
m = Month(InputDate)
Y = Year(InputDate)
'find the first day of next month, then back up one day
WorkDate = DateAdd("m", 1, DateSerial(Y, m, 1)) - 1
d = Day(WorkDate)
m = Month(WorkDate)
Y = Year(WorkDate)
If ReturnAsNumeric = False _
And ReversedOrder = False Then
LastOfMonth = DateSerial(Y, m, d)
Else
If ReturnAsNumeric = False Then
LastOfMonth = Y & "/" & Format(m, "00") & "/" & Format(d, "00")
Else
If ReversedOrder = False Then
LastOfMonth = Format(d, "00") & Format(m, "00") & Y
Else
LastOfMonth = Y & Format(m, "00") & Format(d, "00")
End If
End If
End If
End If
End Function
** As Scott has also suggested the method that you are using to calculate 'Age / Years of Service" is NOT correct ....