Function GetMonthLastDay(WhichDay:TDate):TDate;
var
Year1,Month1,Day1,Year2,Month2:Word;
Begin
Result:=WhichDay;
DecodeDate(WhichDay,Year1,Month1,Day1);
Year2:=Year1;
Month2:=Month1+1;
if Month2=13 then
Begin
Month2:=1;
Year2:=Year2+1;
End;
Result:=EnCodeDate(Year2,Month2,1)-1;
End;
Function GetMonLast(Idate:TDate):TDate;
Var
Year,Month,Day:Word;
Begin
DecodeDate(IDate,Year,Month,Day);
If Month=12 Then
Begin
Year:=year + 1;
Month:=01
End Else Month:= Month + 1;
Result:=Encodedate(Year,Month,01) - 1;
End;