If you mean, you want to convert "130 days" to "4 months, 10 days" (for example), then there's no simple answer to that.
Unfortunately, the number of days in a month varies from month to month (and in the case of February, year to year!) so that can be very difficult to really calculate.
Perhaps the easiest way would be to use a Function call that uses the Day(), Month(), and Year() Functions:
Code:
Public Function DaysInMonth(InputDate) As Integer
DaysInMonth = DateSerial(Year(InputDate), Month(InputDate) + 1, 1) - DateSerial(Year(InputDate), Month(InputDate), 1)
End Function
Public Function DurationToString(DateStart As Date, DateEnd As Date) As Variant
On Error GoTo Error_DurationToString
DurationToString = ""
Dim dteTmp As Date
Dim nbrDay As Integer
Dim nbrMonth As Integer
Dim nbrYear As Integer
If DateStart > DateEnd Then
dteTmp = DateStart
DateStart = DateEnd
DateEnd = dteTmp
End If
' Calculate the number of years
nbrYear = Year(DateEnd) - Year(DateStart)
' Calculate the number of months
nbrMonth = Month(DateEnd) - Month(DateStart)
Do While nbrMonth < 0
nbrMonth = nbrMonth + 12
nbrYear = nbrYear - 1
Loop
' Calculate the number of days
nbrDay = Day(DateEnd) - Day(DateStart)
Do While nbrDay < 0
nbrDay = nbrDay + DaysInMonth(DateSerial(Year(DateStart) + nbrYear, Month(DateStart) + nbrMonth, 1))
nbrMonth = nbrMonth - 1
If nbrMonth < 0 Then
nbrMonth = nbrMonth + 12
nbrYear = nbrYear - 1
End If
Loop
If nbrYear > 1 Then
DurationToString = nbrYear & " years"
ElseIf nbrYear > 0 Then
DurationToString = nbrYear & " year"
End If
If nbrMonth > 0 Then
If Len(DurationToString & vbNullString) > 0 Then
DurationToString = DurationToString & ", "
End If
If nbrMonth > 1 Then
DurationToString = DurationToString & nbrMonth & " months"
ElseIf nbrMonth > 0 Then
DurationToString = DurationToString & nbrMonth & " month"
End If
End If
If nbrDay > 0 Then
If Len(DurationToString & vbNullString) > 0 Then
DurationToString = DurationToString & ", "
End If
If nbrDay > 1 Then
DurationToString = DurationToString & nbrDay & " days"
ElseIf nbrDay > 0 Then
DurationToString = DurationToString & nbrDay & " day"
End If
End If
Function_Closing:
Exit Function
Error_DurationToString:
DurationToString = False
End Function
If you put the above code in a Module, then you can return a string like "4 months, 10 days" just by calling the function DurationToString(DateStart, DateEnd).