bevssi 0 Newbie Poster

My forms include a ministry start date, if the start date is after July, I want to add a year to the number of years in ministry. If the start date is before July then the number of years of ministry would be the actual number of years in ministry. But, when I include the following function, all of my records display 110 for the number of years in ministry. Any suggestions?

<%
!****In Included Functions ASP ****!
Function CalcNumYears(StartDate)
Dim RollingYearStart, Year Offset

If Not IsNull(StartDate) Then
If Month (Now()) >= 7 Then
RollingYearStart = "07/01/" & Year(Now()) + 1
Else
RollingYearStart = "07/01/" & Year(Now())
End If

If Month(StartDate) < Month(RollingYearStart) Then
YearOffset = 1
Else
YearOffset = 0
End If

CalcNumYears = DateDiff("yyyy", StartDate, RollingYearStart) + YearOffset
Else
CalcNumYears = 0
End If

End Function
%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.