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

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

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

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

posted @ 2018-04-03 09:29  神只吃苹果  阅读(3917)  评论(0编辑  收藏  举报