I always use the time comparison, I found some information, and found that although there are a lot of things on the Internet, it is quite messy. Then do some experiments yourself and record them here. . . .
1 SELECT 2 sysdate - DEADLINE, 3 DEADLINE 4 FROM T_FUNC_MISSION;
sysdate is the oracle system time;
The output result is: -6 8:1:34.0 2018-04-30 23:50:00.000000 Obviously, this method can compare the time, the method is simple, but a bit low.
Continue to find information:
https://www.cnblogs.com/xuxm2007/archive/2010/12/28/1918652.html
This introduction is very detailed, but I found that many of them are not available for Oracle, and they are basically functions in SQL Server. . . . -_-||,
http://liwx.iteye.com/blog/1236382
The oracles introduced in this article can be used, but there is still a pit. .
1 select sysdate,to_date('2009-2-20 17:45:39','yyyy-mm-dd hh24:mi:ss'), 2 ROUND(TO_NUMBER(sysdate - to_date('2009-2-20 17:45:39','yyyy-mm-dd hh24:mi:ss')) * 24 * 60) 3 from dual;
Such sql can be run, but if it is set to its own table, it will report an error, an invalid number.
At first, I thought that the format in to_number was wrong, and the converted string must conform to the numeric type format.
to_number is one of the commonly used type conversion functions in Oracle. It is a format for converting a string to a numeric type, which is the opposite of the TO_CHAR() function.
https://blog.csdn.net/dongdong9223/article/details/48972815 has an introduction
But why is there no error when querying the dual table? ? ? Weird. . . .
SELECT sysdate - DEADLINE FROM T_FUNC_MISSION; SELECT sysdate - to_date('2018-4-20 17:45:39', 'yyyy-mm-dd hh24:mi:ss') FROM dual;
The field type found from the dual table is the number type, but the field found in the T_FUNC_MISSION table is the intervalds type (time difference);
Still have some questions:
Is the dual table any different?
Make a note. . . . .