select autoid from order_t where acceptdate=to_date('2010-01-01', 'yyyy-MM-dd')
数据库里明明有满足条件的记录可是却出不来.为什么
select autoid from order_t where acceptdate>=to_date('2010-01-01', 'yyyy-MM-dd') and acceptdate<=to_date('2010-01-01','yyyy-MM-dd')
上面的两个都不行..
高手指教
数据库里明明有满足条件的记录可是却出不来.为什么
select autoid from order_t where acceptdate>=to_date('2010-01-01', 'yyyy-MM-dd') and acceptdate<=to_date('2010-01-01','yyyy-MM-dd')
上面的两个都不行..
高手指教
按你的SQL,应该是没有符合条件的数据
你数据库中acceptdate字段存放的日期格式是什么样的? 是不是yyyy-MM-dd? 那么就查不出
你试试这样有数据没的呢?select autoid from order_t where To_Char(acceptdate,'yyyy-MM-dd')='2010-01-01';
用这句试试
或者
select autoid from order_t where acceptdate between to_date('2010-01-01', 'yyyy-MM-dd') and to_date('2010-01-02','yyyy-MM-dd')
2010-01-01 12:12:12 和2010-01-01是不等的To_Char(acceptdate,'yyyy-MM-dd')='2010-01-01';
scott@ORCL> insert into emp
2 (empno,ename,hiredate) values(8888,'john',to_date('1981-02-20 10:25:32',
3 'yyyy-mm-dd hh24:mi:ss'));1 row created.scott@ORCL> select * from emp where to_char(hiredate,'yyyy-mm-dd')='1981-02-20'
2 ; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
8888 john 1981-02-20 10:25:32
7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00 1500 300 30scott@ORCL> select * from emp
2 where to_char(hiredate,'yyyy-mm-dd')>='1981-02-19'
3 and to_char(hiredate,'yyyy-mm-dd')<'1981-02-21'; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
8888 john 1981-02-20 10:25:32
7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00 1500 300 30