DATEDIFF function in Oracle

前端 未结 4 1941
难免孤独
难免孤独 2020-11-30 10:55

I need to use Oracle but DATEDIFF function doesn\'t work in Oracle DB.

How to write the following code in Oracle? I saw some examples using INTERVAL or TRUNC.

4条回答
  •  没有蜡笔的小新
    2020-11-30 11:17

    Just subtract the two dates:

    select date '2000-01-02' - date '2000-01-01' as dateDiff
    from dual;
    

    The result will be the difference in days.

    More details are in the manual:
    https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements001.htm#i48042

提交回复
热议问题