如题。
mid('202103',1,4)*12+mid('202103',5,2)-(mid('202012',1,4)*12+mid('202012',5,2))
https://help.fanruan.com/finereport/doc-view-819.html?source=4#5
注意:202103格式需要拼接成20210301格式
select datediff(month, 开始日期,结束日期); --两日期间隔月,试试
DATEDIF(date(left(202012,4),mid(202012,5,2),01),date(left(202103,4),mid(202103,5,2),01),"M")+1
DATEDIF("2021/01/26","2021/04/26",'M') = 3