/*
Function Name :- MonthsBetweenMonths(firstDate;lastDate)
———————————————————–
firstDate and lastDate should be non empty
Date Format :- mm/dd/yyyy
Example:- firstDate = “5/1/2014″ , lastDate =”5/20/2014” , result =0
firstDate = “5/1/2014″ , lastDate =”4/16/2014” , result =-1
firstDate = “5/1/2014″ , lastDate =”2/8/2014” , result =-2
firstDate = “5/1/2014″ , lastDate =”6/12/2014” , result =1
firstDate = “5/1/2014″ , lastDate =”7/12/2014” , result =2
firstDate = “5/1/2014″ , lastDate =”8/12/2014” , result =3
*/
If ( not IsEmpty ( firstDate ) and not IsEmpty ( lastDate );
If ( GetAsDate ( lastDate ) ≥ GetAsDate ( firstDate ) ;
Let (
[ year_last=Year ( lastDate ) ;
year_first =Year (firstDate ) ;
month_first = Month ( firstDate );
month_last = Month ( lastDate );
month_total= Case (
year_last = year_first and month_last ≥ month_first ; month_last – month_first ;
year_last = year_first +1 ; month_last + (12- month_first) ;
year_last – year_first ≥ 2 ; (year_last – year_first)*12 + (12- month_first) + month_last ;
) ];
month_total
)
;
Let (
[ year_last=Year ( lastDate ) ;
year_first =Year (firstDate ) ;
month_first = Month ( firstDate );
month_last = Month ( lastDate );
month_total= Case (
year_last = year_first and month_last < month_first; month_first- month_last ;
year_last = year_first-1 ; 12- month_last + month_first ;
year_first – year_last ≥ 2 ; ( year_first – year_last )*12 + 12 – month_last +1 ;
) ];
“-” & month_total
)
)
;””)