Public Type tPeriod
Begin As Date
End As Date
End Type
'A начало первого периода
'B конец первого периода
'C начало второго периода
'D конец второго периода
Public Function GetPeriod(A As Date, B As Date, C As Date, D As Date) As tPeriod
If D < A Or C > B Then
Exit Function
Else
With GetPeriod
.Begin = Major(A, C)
.End = Minor(B, D)
End With
End If
End Function
Public Function Minor(B As Date, D As Date) As Date 'Min
If D < B Then
Minor = D
Else
Minor = B
End If
End Function
Public Function Major(A As Date, C As Date) As Date 'Max
If C > A Then
Major = C
Else
Major = A
End If
End Function
|