In G2 copied down.

Formula: copy to clipboard
=IF(C2=C1,IF(D2=E1+1,DATEDIF(D1,E2,"m"),""),"")