Home Oracle 计算时间差
Post
Cancel

Oracle 计算时间差

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SELECT
    param1,
    param2,
    param3
FROM
    TEST T
WHERE
    TO_NUMBER (
        TO_DATE (
            TO_CHAR (T.modifydate, 'yyyy-mm-dd hh24:mi:ss'),
            'yyyy-mm-dd hh24:mi:ss'
        ) - 
        TO_DATE (
            TO_CHAR (T.createdate, 'yyyy-mm-dd hh24:mi:ss'),
            'yyyy-mm-dd hh24:mi:ss'
        )
    ) * 86400 > 2 * 24 * 60 * 60
1
2
3
4
5
6
7
8
9
SELECT
    param1,
    param2,
    param3
FROM
    TEST T
WHERE
    T.createdate <![CDATA[<]]> (SYSDATE - 1/12)
-- SYSDATE为Date类型,可以直接减,不用转换格式。
This post is licensed under CC BY 4.0 by the author.