select * from tablename where date between to_date('20101120','yyyymmdd') and to_date('20101130','yyyymmdd')
月份信息是要通过strDate中获取的,所以不能写死的
select * from tablename where date between to_date('20101120','yyyymmdd') and last_day(to_date('20101120','yyyymmdd'))+1-1/24/60/60
用last_day函数获取本月的最后一天啊
如果你只是存储了天的信息的话,直接 select * from tablename where date between to_date('20101120','yyyymmdd') and last_day(to_date('20101120','yyyymmdd'))
select * from tablename where date between to_date(strdate,'yyyymmdd') and last_day(to_date(strdate,'yyyymmdd'))
dt between to_date(strDate,'yyyymmdd') and last_day(to_date(strDate,'yyyymmdd'))
between trunc(to_date(strDate,'yyyymmdd'),'mm') and to_date(strDate,'yyyymmdd')
dt between trunc(to_date(strDate,'yyyymmdd'),'mm') and to_date(strDate,'yyyymmdd')
select * from tablename where date between to_date(strdate,'yyyymmdd') and last_day(to_date(strdate,'yyyymmdd')) select * from tablename where date between trunc(to_date(strDate,'yyyymmdd'),'mm') and to_date(strDate,'yyyymmdd')
为什么会报ora00904的错 SELECT Date,Value FROM TableName WHERE A=A AND Date between to_date(strDate,'YYYYMMDD') and last_day(to_date(strDate,'YYYYMMDD')) order by Date
--你的strdate是从另个一表里读出来的? 给你个例子 已写入 file afiedt.buf 1 with tb as( 2 select '19810211' strdate from dual) 3 select emp.* from emp,tb 4 where hiredate between to_date(strdate,'yyyymmdd') 5* and last_day(to_date(strdate,'yyyymmdd')) SQL> / EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- -------------- ---------- ---------- ---------- 7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30 7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30
怎么命名字段跟关键字一样 忌讳 你date字段是字符型的A=A AND ---没必要弄个开关放在这 除非是动态 SELECT Date,Value FROM TableName WHERE to_date(Date'YYYYMMDD') between to_date(strDate,'YYYYMMDD') and last_day(to_date(strDate,'YYYYMMDD')) order by Date
select * from tablename
where date between to_date('20101120','yyyymmdd') and to_date('20101130','yyyymmdd')
where date between to_date('20101120','yyyymmdd') and last_day(to_date('20101120','yyyymmdd'))+1-1/24/60/60
select * from tablename
where date between to_date('20101120','yyyymmdd') and last_day(to_date('20101120','yyyymmdd'))
where date between to_date(strdate,'yyyymmdd')
and last_day(to_date(strdate,'yyyymmdd'))
between trunc(to_date(strDate,'yyyymmdd'),'mm') and to_date(strDate,'yyyymmdd')
select * from tablename
where date between to_date(strdate,'yyyymmdd')
and last_day(to_date(strdate,'yyyymmdd'))
select * from tablename
where date between trunc(to_date(strDate,'yyyymmdd'),'mm') and to_date(strDate,'yyyymmdd')
SELECT Date,Value FROM TableName WHERE A=A AND Date between to_date(strDate,'YYYYMMDD') and last_day(to_date(strDate,'YYYYMMDD')) order by Date
只有是20101011 这样的就可以 要有单引号的哦 '20101011'
--你的strdate是从另个一表里读出来的? 给你个例子
已写入 file afiedt.buf 1 with tb as(
2 select '19810211' strdate from dual)
3 select emp.* from emp,tb
4 where hiredate between to_date(strdate,'yyyymmdd')
5* and last_day(to_date(strdate,'yyyymmdd'))
SQL> / EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------------- ---------- ---------- ----------
7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30
7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30
SELECT Date,Value FROM TableName WHERE to_date(Date'YYYYMMDD') between to_date(strDate,'YYYYMMDD') and last_day(to_date(strDate,'YYYYMMDD')) order by Date