字段为date,value,现获取到一个字符串类型的日期strDate(格式“YYYYMMDD”),如何查找strDate标识日期所在月,自strDate当日到月末的所有记录。
如:strDate=20101120,如何查询11月20日到11月30日的记录
如:strDate=20101120,如何查询11月20日到11月30日的记录
解决方案 »
- 在linux如何用C调用oracle以数组作为参数的存储过程,谢谢!
- PLSQL如何快速打出select * from
- commit怎么加?
- 为什么报未明确定义列的错
- oracle可以计算微积分吗?
- sql语句转换的问题。
- 我是Oracle 的初学者,只用过sql server,想学Oracle 8i请大家指教。不给分是小狗!
- 我装有两个OS,在简体的win2003上装了个oracle9,发现在OEM里包错的框里的汉字都变成了????,有社么办法吗?
- linux下的make为何会自动删除预编译输出的中间文件*.c?
- 怎样从文本文件读内容到数据库????????
- Windows2003 Server系统无法安装Oracle 10g
- 字符集
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