Function DDateTexte$(Date1 As Date, Date2 As Date) 'ROGER2327
'Utilise DDate1
Dim v()
' Application.Volatile 'Facultatif
v = DDate1(Date1, Date2)
DDateTexte = _
v(0) & " an" & IIf(v(0) > 1, "s, ", ", ") & _
v(1) & " mois et " & _
v(2) & " jour" & IIf(v(2) > 1, "s", "")
End Function
Function DDate1(ByVal D As Date, ByVal F As Date) 'ROGER2327
'Utilise DecMois
Dim T&, Jo%
F = Int(F) - (Round(F - Int(F) - D + Int(D), 6) >= 0)
T = 12 * (Year(F) - Year(D)) + Month(F) - Month(D)
T = T + (DecMois(D, T) >= F)
Jo = F - DecMois(D, T) - 1
DDate1 = Array(T \ 12, T Mod 12, Jo) 'Renvoie un vecteur-ligne à trois composantes.
End Function
Function DecMois(D As Date, dec&) As Long 'ROGER2327
Dim x&, y&
x = DateSerial(Year(D), Month(D) + dec, 1)
y = Day(DateSerial(Year(x), Month(x) + 1, 0))
If y < Day(D) Then DecMois = x + y - 1 Else DecMois = x + Day(D) - 1
End Function