oracle函数 months_between(d1,d2)

【功能】:返回日期d1到日期d2之间的月数。

【参数】:d1,d2 日期型

 

【返回】:数字

如果d1>d2,则返回正数

如果d1<d2,则返回负数

 

【示例】

select sysdate,

months_between(sysdate,to_date('2006-01-01','YYYY-MM-DD')),

months_between(sysdate,to_date('2016-01-01','YYYY-MM-DD')) from dual;

 

返回:2008-11-5,34.16,-85.84

猜你喜欢

转载自www.cnblogs.com/fanweisheng/p/11119852.html