oracle的时间处理

来源:互联网 发布:纳米水离子 知乎 编辑:程序博客网 时间:2024/05/21 18:39

相隔多少天:

select trunc(sysdate-hiredate) from emp;

相距多少月:

select trunc(MONTHS_BETWEEN(sysdate,hiredate)) month from emp;

相隔多少年,月,日;

select empno,trunc(MONTHS_BETWEEN(sysdate,hiredate)/12) year,

 trunc(mod(MONTHS_BETWEEN(sysdate,hiredate),12)) month,

 trunc(sysdate-add_months(hiredate,MONTHS_BETWEEN(sysdate,hiredate))) day

from emp;

4月份入职员工:

select * from emp where to_char(hiredate,'mm')=4;

本月倒数第三天入职员工:
select *from emp where hiredate=last_day(hiredate)-2

 

 

http://localhost:8080/springmvc_demo/pages/Wxyproject/list.do

原创粉丝点击