MicroStrategy ONE

MonthsBetween

Returns the difference in months between two dates, as an integer value. The difference is calculated on the number of months elapsed and not on the number of month boundaries crossed. If the first date argument is later than the second date argument, the result is a negative number. The result does not display the timestamps as they are truncated before performing the calculation.

Syntax

MonthsBetween(Date/Time1, Date/Time2)

Where

Date/Time1 is the start date and Date/Time2 is the end date.

For information on the syntax used in your specific database, refer to the Functions Reference.

Example

MonthsBetween('2024-07-29', '2024-02-28') = -5

MonthsBetween('2024-07-29 02:00:00', '2024-09-29 01:00:00') = 2