直接相减
select date1-date2 from dual; --天
select months_between(date1,date2) from dual; --月
select to_char(date1,'yyyy')-to_char(date2,'yyyy') from dual;--年
select date1-date2 from dual; --天
select months_between(date1,date2) from dual; --月
select to_char(date1,'yyyy')-to_char(date2,'yyyy') from dual;--年
datetime1 := to_date('2004-05-01 23:24:56','yyyy-mm-dd hh24:mi:ss');
datetime2 := to_date('2004-05-02 03:24:56','yyyy-mm-dd hh24:mi:ss');date2 - date1 = 0.166666667但我实际需要的天数差应该等于 1 啊,请问如何解决啊
datetime1 := to_date('2004-05-01 23:24:56','yyyy-mm-dd hh24:mi:ss');
datetime2 := to_date('2004-05-02 03:24:56','yyyy-mm-dd hh24:mi:ss');trunc(date2 - date1) = 0