Skip to content

Flow documentation · legacy product

MonthsBetween ​

Declaration ​

Function MonthsBetween(const ANow: TDateTime; const AThen: TDateTime): Integer

Example ​

pascal
procedure OnMapEvent(var Value:Variant);
begin
// test two dates that are 101 days apart ...
  Value := MonthsBetween(Date, IncDay(Date, 101)); // result is 3 (whole months, approximately)
end;

Description ​

Returns the approximate number of months between two specified TDateTime values. Because months are not all the same length, MonthsBetween returns an approximation based on an assumption of 30.4375 days per month. Fractional months are not counted. Thus, for example, MonthsBetween reports the difference between Feb 1 and Mar 1 as 0.

The ordering of the two dates doesn't matter - the number of months will not be negative.