Function Decompte(DateEntree, DateSortie, DateDeb, DateFin)
If DateEntree <= DateFin Then
deb = IIf(DateEntree < DateDeb, DateDeb, DateEntree)
Else
Decompte = 0 '"pas encore entré"
Exit Function
End If
If DateSortie = "" Then
If Month(Date) >= Month(DateFin) Then
fin = DateFin
Else
Decompte = 0 '" on n' est pas arrivé à cette période"
Exit Function
End If
Else
If DateSortie >= DateDeb Then
fin = IIf(DateSortie <= DateFin, DateSortie, DateFin)
Else
Decompte = 0 '"déjà parti"
Exit Function
End If
End If
Decompte = fin - deb + 1
End Function