Function P_Date_Date(_FirstDate,_EndDate:String):String;
Var
i:Byte;
Str1,Str2,Str3,Str4,Str5,Str6,Final:ShortString;
_CheckLengh:Boolean;
Begin
If (Length(_FirstDate)=8) AND (Length(_EndDate)=8) Then
Begin
For i:=7 To 8 Do Str1:=Str1+_FirstDate[i];
For i:=7 To 8 Do Str2:=Str2+_EndDate[i];
For i:=4 To 5 Do Str3:=Str3+_FirstDate[i];
For i:=4 To 5 Do Str4:=Str4+_EndDate[i];
For i:=1 To 2 Do Str5:=Str5+_FirstDate[i];
For i:=1 To 2 Do Str6:=Str6+_EndDate[i];
_CheckLengh:=True;
End
Else
If (Length(_FirstDate)=10) AND (Length(_EndDate)=10) Then
Begin
For i:=9 To 10 Do Str1:=Str1+_FirstDate[i];
For i:=9 To 10 Do Str2:=Str2+_EndDate[i];
For i:=6 To 7 Do Str3:=Str3+_FirstDate[i];
For i:=6 To 7 Do Str4:=Str4+_EndDate[i];
For i:=1 To 4 Do Str5:=Str5+_FirstDate[i];
For i:=1 To 4 Do Str6:=Str6+_EndDate[i];
_CheckLengh:=True;
End
Else
_CheckLengh:=False;
If _CheckLengh Then
Begin
Str5:=IntToStr(StrToInt(Str5)*365);
Str6:=IntToStr(StrToInt(Str6)*365);
If Str3<='6' Then Str5:=IntToStr((StrToInt(Str5)+StrToInt(Str3)*31)) ;
If Str4<='6' Then Str6:=IntToStr((StrToInt(Str6)+StrToInt(Str4)*31)) ;
If (Str3>'6') and (Str3<='12') Then
Begin
Str3:=IntToStr(StrToInt(Str3)-6);
Str5:=IntToStr((StrToInt(Str5)+(StrToInt(Str3)*30) +186));
End;
If (Str4>'6') and (Str4<='12') Then
Begin
Str4:=IntToStr(StrToInt(Str4)-6);
Str6:=IntToStr((StrToInt(Str6)+(StrToInt(Str4)*30) +186));
End;
Str5:=intToStr(StrToInt(Str5)+(StrToInt(Str1)));
Str6:=intToStr(StrToInt(Str6)+(StrToInt(Str2)));
Final:=intToStr(StrToInt(Str6)-(StrToInt(Str5)));
Result:=Final;
End;
End;