How to find the difference between two dates and return the corresponding number of months in Dynamics NAV
You could use a variable Calendar > Record > Date IF ( FromDate <> 0D ) and ( ToDate > FromDate ) THEN BEGIN Calendar . RESET ; Calendar . SETRANGE ( "Period Type" , Calendar . "Period Type" :: Month ); Calendar . SETRANGE ( "Period Start" , FromDate , ToDate ); Months := Calendar . COUNT ; END ELSE Months := 0 ; The problem with this type of code is 01 Jan 07 to 01 Feb 07 will return 2 Months. When it is only 1 month 1 day! 31/01/06 and 01/02/06 will be 1 month between 01/01/06 and 28/02/06 will be 2 Months Date Difference in months.