select * from table where trunc(bu_date)>=TO_DATE('2004-11-10','YYYY-MM-DD') and trunc(bu_date)<=TO_DATE('2004-11-10','YYYY-MM-DD') order by bu_date desc;orselect * from table where bu_date>=TO_DATE('2004-11-10','YYYY-MM-DD') and bu_date<=TO_DATE('2004-11-11','YYYY-MM-DD') order by bu_date desc;
那么如下即可,
SQL> select * from aa;MYDATE
---------
11-NOV-04
11-NOV-04SQL> select * from aa where to_char(mydate,'yyyy-mm-dd')='2004-11-11';MYDATE
---------
11-NOV-04
11-NOV-04SQL> desc aa
Name Null? Type
----------------------------------------- -------- ----------------------
MYDATE DATE
select * from table where bu_date like TO_DATE('2004-11-10','YYYY-MM-DD') order by bu_date desc";
或者转为字符串比较
select * from table where to_char(bu_date,'yyyy-mm-dd') = '2004-11-10' order by bu_date desc";
select * from table where trunc(bu_date,'dd')>=TO_DATE('2004-11-10','YYYY-MM-DD') and trunc(bu_date,'dd')<=TO_DATE('2004-11-10','YYYY-MM-DD') order by bu_date desc";trunc的作用是把日期类型的精确到天,不计后面的时分秒,当然,精确度可由你自己决定.
select * from table where to_char(bu_date,'yyyy-mm-dd')>='2004-11-10' and to_char(bu_date,'yyyy-mm-dd')<='2004-11-10' order by bu_date desc