Hi can anyone please help!!
I am using the below code to calculate the Years,Months,Days between two dates, but I want to use the current date if my End Date is empty..
How would I do this?
Public Function Calcdays(StartDate As Date, EndDate As Date) As String
Dim intYears As Integer, intMonths As Integer, intDays As Integer
intMonths = DateDiff("m", StartDate, EndDate)
intDays = DateDiff("d", DateAdd("m", intMonths, StartDate), EndDate)
If intDays < 0 Then
intMonths = intMonths - 1
intDays = DateDiff("d", DateAdd("m", intMonths, StartDate), EndDate)
End If
intYears = intMonths \ 12
intMonths = intMonths Mod 12
Calcdays = " " & intYears & " Years, " & intMonths & " Months, " & intDays & " Days"
End Function
My result is =Calcdays([StartDate],[EndDate])
I am using the below code to calculate the Years,Months,Days between two dates, but I want to use the current date if my End Date is empty..
How would I do this?
Public Function Calcdays(StartDate As Date, EndDate As Date) As String
Dim intYears As Integer, intMonths As Integer, intDays As Integer
intMonths = DateDiff("m", StartDate, EndDate)
intDays = DateDiff("d", DateAdd("m", intMonths, StartDate), EndDate)
If intDays < 0 Then
intMonths = intMonths - 1
intDays = DateDiff("d", DateAdd("m", intMonths, StartDate), EndDate)
End If
intYears = intMonths \ 12
intMonths = intMonths Mod 12
Calcdays = " " & intYears & " Years, " & intMonths & " Months, " & intDays & " Days"
End Function
My result is =Calcdays([StartDate],[EndDate])