如何在 Oracle 11g 中获取两个日期之间的天数?

2021-12-06 00:00:00 sql oracle11g oracle

我试图在 Oracle 11g 中找到两个日期之间的整数天数.

I'm trying to find an integer number of days between two dates in Oracle 11g.

我可以通过做来接近

select sysdate - to_date('2009-10-01', 'yyyy-mm-dd') from dual

但这会返回一个间隔,我还没有成功地将它转换为整数.

but this returns an interval, and I haven't been successful casting this to an integer.

显然在 10g 中,这会以整数形式返回天数.

Apparently in 10g, this returns the number of days as an integer.

推荐答案

我自己想出来的.我需要

I figured it out myself. I need

select extract(day from sysdate - to_date('2009-10-01', 'yyyy-mm-dd')) from dual

相关文章