oracle中两个时间类型的数据相减默认得到的是天数。

想要得到月份数,需要使用months_between函数。

months_between(to_date('201707','yyyyMM'),to_date('201706','yyyyMM'))   得到1个月份

to_date('201707','yyyyMM')-to_date('201706','yyyyMM')   得到30天

原文地址:https://www.cnblogs.com/shenzhichipingguo/p/8706237.html