months_between
转自:https://www.cnblogs.com/pumushan/p/6655204.html
格式:months_between(DATE1,DATE2) MONTHS_BETWEEN函数返回两个日期之间的月份数。 sql> select months_between(to_date('20090228', 'yyyymmdd'), to_date('20080228', 'yyyymmdd')) as months from dual; MONTHS ---------- 12 SQL> select months_between(to_date('20090228', 'yyyymmdd'), to_date('20080229', 'yyyymmdd')) as months from dual; MONTHS ---------- 12 SQL> select months_between(to_date('20080229', 'yyyymmdd'), to_date('20070228', 'yyyymmdd')) as months from dual; MONTHS ---------- 12 SQL> select months_between(to_date('20100331', 'yyyymmdd'), to_date('20100228', 'yyyymmdd')) as months from dual; MONTHS ---------- 1 SQL> select months_between(to_date('20100228', 'yyyymmdd'), to_date('20100128', 'yyyymmdd')) as months from dual; MONTHS ---------- 1 SQL> select months_between(to_date('20100327', 'yyyymmdd'), to_date('20100228', 'yyyymmdd')) as months from dual; MONTHS ---------- .967741935 SQL> select months_between(to_date('20100330', 'yyyymmdd'), to_date('20100228', 'yyyymmdd')) as months from dual; MONTHS ---------- 1.06451613 SQL> select months_between(to_date('20100228', 'yyyymmdd'), to_date('20100130', 'yyyymmdd')) as months from dual; MONTHS ---------- .935483871 SQL> select months_between(to_date('20100228', 'yyyymmdd'), to_date('20100131', 'yyyymmdd')) as months from dual; MONTHS ---------- 1 SQL> select months_between(to_date('20100228', 'yyyymmdd'), to_date('20100127', 'yyyymmdd')) as months from dual; MONTHS ---------- 1.03225806 30/31=0.96774193548387096774193548387097 33/31=1.0645161290322580645161290322581 29/31=0.93548387096774193548387096774194 32/31=1.032258064516129032258064516129 在oracle中计算月份的差值,都是月底或是日期相同,都会按整月计算。 如果计算结果不是整数,ORACLE会把31作为分母来计算。
相关阅读
回调函数与钩子函数 1、什么是回调函数? 简而言之,回调函数就是一个通过函数指针调用的函数。如果你把函数的指针(地址)作为参数传递
描述 uniform() 方法将随机生成下一个实数,它在 [x, y) 范围内。 语法 以下是 uniform() 方法的语法: import random rando
/*** Calendar:日历类* add() roll()* @author Administrator**/public class CalendarDemo {/** * @param args */ public sta
sockaddr_in与sockaddr的区别,以及对网络字节序和主机
一、sockaddr sockaddr在/usr/include/bits/socket.h下,查看sockaddr的结构: struct sockaddr { __SOCKADDR_COMMON (sa_);
l 虚函数是一种在基类定义为virtual的函数,并在一个或多个派生类中再定义的函数。虚函数的特点是,只要定义一个基类的指针,就可以