TO_TIMESTAMP比较

时间:2018-10-18 23:27:41

标签: sql oracle sql-timestamp

SELECT  lastmoddate
        , to_timestamp(lastmoddate,'DD-MON-YYYY HH:MI:SS:FF AM')
        , cast(current_timestamp - interval '60' day as TIMESTAMP)
FROM table 
WHERE primaryKeyColumn = 12141969;

返回:

enter image description here

SELECT problemid
       , lastmoddate
       , to_timestamp(lastmoddate,'DD-MON-YYYY HH:MI:SS:FF AM')
       , cast((current_timestamp - 60) as TIMESTAMP)
FROM table 
WHERE primaryKeyColumn = 12141969
and to_timestamp(lastmoddate,'DD-MON-YYYY HH:MI:SS:FF AM') < cast((current_timestamp - 60)  as TIMESTAMP);

返回:

enter image description here

我不知道8月25日要比8月19日少。

1 个答案:

答案 0 :(得分:0)

感谢所有人,尤其是戈登,加里。你们钉了它。当我运行to_CHAR(lastmoddate,'DD-MON-YYYY HH24:MI')时,我注意到它在Year中存储了0018。这解决了我的问题