Home > database >  Oracle comparison date range is not accurate
Oracle comparison date range is not accurate

Time:09-20

Select objid from SZJXJG. Ms_task_baseinfo m where m. asktypecode in (' C007) and m. askstate!
='9'And to_date (to_char (m. inishdate, 'mm - dd yyyy -'), '- dd yyyy - mm) between to_date (' 2018-11-10', '- dd yyyy - mm) and to_date (' 2018-11-15', '- dd yyyy - mm)


The result set there is always a few do not meet the date range


The CREATE TABLE MY_TABLE (
ROWNUM_ NUMBER,
OBJID VARCHAR2,
ENTID VARCHAR2,
ENTREGNO VARCHAR2,
LICENSE_NO VARCHAR2,
ENTNAME VARCHAR2,
DOM VARCHAR2,
ENTTYPE VARCHAR2,
UNEXECUTEOTHERREASON VARCHAR2,
UNEXECUTEREASON VARCHAR2,
PERNAME VARCHAR2,
JGS_NAME VARCHAR2,
LEREPNAME VARCHAR2,
VALIDITYTO VARCHAR2,
VALIDITYFROM VARCHAR2,
MOBILEINSPECTCOUNT NUMBER,
FINISHDATE VARCHAR2
);
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' has been out of business, has been closed, no such effect ', 'LXJ', 'by dapeng', 'Tang Xiaohui', '2021-06-15', '2016-06-16', 25, '2018-11-15');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'wys',' by dapeng ', 'zhang hy', '2021-05-30', '2016-05-31', 19, '2018-11-14');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' has been closed, no such effect ', 'L', 'what south Australia', 'ming-wei liu', '2021-06-19', '2016-06-20', 16, '2018-11-15');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'wys',' by dapeng ', 'to the gentry wu', '2021-07-03', '2016-07-04', 19, '2018-11-16');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' no such effect ', 'jhon', 'by dapeng', 'ZhongJingGao', '2021-07-19', '2016-07-20', 4, '2018-11-15');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' refused to check ', 'jhon', 'kwai chung by', 'Li Yuxiao', '2021-07-10', '2016-07-11', 5, '2018-11-14');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'L', 'what south Australia', 'Zheng Yuemei', '2021-06-30', '2016-07-01', 13, '2018-11-15');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'jhon', 'kwai chung by', 'yong-jun Chen', '2021-06-28', '2016-06-29', 5, '2018-11-13');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'jhon', 'kwai chung by', 'Han Hongmin', '2021-07-27', '2016-07-28', 5, '2018-11-27');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'jhon', 'kwai chung by', 'Fang Wenying', '2021-08-07', '2016-08-08', 5, '2018-11-10');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'jhon', 'kwai chung by', 'wen-lin zhang', '2021-09-28', '2016-09-29', 5, '2018-11-13');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' no such effect ', 'jhon', ' 'the kwai chung,' kowalski b r. correction group ', '2021-10-23', '2016-10-24', 5, '2018-11-14');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' no such effect ', 'jhon', 'kwai chung by', 'Li Lixian', '2021-10-24', '2016-10-25', 5, '2018-11-14');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'jhon', 'kwai chung by', 'Li Feng', '2021-10-18', '2016-10-19', 5, '2018-11-12');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' has been out of business, has been out of business ', 'NHY', 'what south Australia', 'isaceli rs Ming', '2021-10-27', '2016-10-28', 16, '2018-11-15');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' no such effect ', 'WSP', 'by dapeng', 'Chen Jiangbiao', '2021-10-27', '2016-10-28', 23, '2018-11-15');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (null, 'jhon', 'kwai chung by', 'strategies',' 2021-11-20 ', '2016-11-21', 5, '2018-11-10');
INSERT INTO MY_TABLE (UNEXECUTEREASON, PERNAME JGS_NAME, LEREPNAME, VALIDITYTO, VALIDITYFROM, MOBILEINSPECTCOUNT, FINISHDATE) VALUES (' has been closed, refused to check, no such effect, no such effect, refused to check, has been out of business, has been closed, no such effect, have been closed, no such effect, no such effect, no such effect, no such effect, have been out of business, refused to check other ', 'Ma Mingfei', 'kwai chung by', 'blue', '2018-12-29', '2018-08-27', 106, '2018-12-04');

CodePudding user response:

Do not conform to the case?

CodePudding user response:

Syntax error, and there is no "tasktypecode" this field
  • Related