select extract(year from sysdate) as year , extract(month from sysdate) as month, extract(day from sysdate) as day from dual; //使用extract()函数,分别取出年月日
YEAR MONTH DAY ---------- ---------- ---------- 2020 10 26
select extract(day from d2 - d1) from ( select to_timestamp('2020-5-15 5:00:00','yyyy-mm-dd hh24:mi:ss') d2, to_timestamp('1985-5-15 5:00:00','yyyy-mm-dd hh24:mi:ss') d1 from dual);//计算d2倒d1相差多少天
EXTRACT(DAYFROMD2-D1) --------------------- 12784