1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Function EntreDeuxDates(Date1 As Variant, Date2 As Variant, Annee1 As Variant, Mois1 As Variant)
If (Month(Date1) = Mois1 And Year(Date1) = Annee1) Or (Month(Date2) = Mois1 And Year(Date2) = Annee1) Or (Date1 < DateSerial(Annee1, Mois1, 1) And Date2 > DateSerial(Annee1, Mois1 + 1, 1) - 1) Then
If Date1 < DateSerial(Annee1, Mois1, 1) Then
If Date2 > (DateSerial(Annee1, Mois1 + 1, 1) - 1) Then
EntreDeuxDates = (DateSerial(Annee1, Mois1 + 1, 1) - 1) - (DateSerial(Annee1, Mois1, 1)) + 1
Else
EntreDeuxDates = DateSerial(Year(Date2), Month(Date2), Day(Date2)) - (DateSerial(Annee1, Mois1, 1)) + 1
End If
Else
If Date2 > DateSerial(Annee1, Mois1 + 1, 1) - 1 Then
EntreDeuxDates = (DateSerial(Annee1, Mois1 + 1, 1) - 1) - Date1 + 1
Else
EntreDeuxDates = Date2 - Date1 + 1
End If
End If
Else
End If
End Function |
Partager