比如 查询 开始时间 2010-10-10 08,
结束时间 2010-10-11 08,结果为
2010-10-10 08
2010-10-10 09
2010-10-10 10
2010-10-10 11
2010-10-10 12
2010-10-10 13
2010-10-10 14
2010-10-10 15
2010-10-11 08 现在做了一个只能 查指定日期之间 天的 sql,
Select Rownum, to_date('2010-12-18 08', 'yyyy-mm-dd hh24:mi:ss')+Rownum-1 tm
from dual connect by rownum< = to_date('2010-12-20 08', 'yyyy-mm-dd hh24:mi:ss')- to_date('2010-12-18 08', 'yyyy-mm-dd hh24:mi:ss') +1;
结果为
2010-12-18 08:00:00
2010-12-19 08:00:00
2010-12-20 08:00:00
怎么样改成上面那种小时的形式?
结束时间 2010-10-11 08,结果为
2010-10-10 08
2010-10-10 09
2010-10-10 10
2010-10-10 11
2010-10-10 12
2010-10-10 13
2010-10-10 14
2010-10-10 15
2010-10-11 08 现在做了一个只能 查指定日期之间 天的 sql,
Select Rownum, to_date('2010-12-18 08', 'yyyy-mm-dd hh24:mi:ss')+Rownum-1 tm
from dual connect by rownum< = to_date('2010-12-20 08', 'yyyy-mm-dd hh24:mi:ss')- to_date('2010-12-18 08', 'yyyy-mm-dd hh24:mi:ss') +1;
结果为
2010-12-18 08:00:00
2010-12-19 08:00:00
2010-12-20 08:00:00
怎么样改成上面那种小时的形式?
解决方案 »
- 菜鸟求助:如何实现条件插入?
- 在线等……新手在此…大神进…
- declare 请问下提示第3行第7列select没有into
- 有关SQL语句,问简单的三个问题;
- 子存储过程调用父存储过程创建的临时表,可以么?
- Oracle9i win2000 server 中安装失败!!!
- SQL语句to_char(to_date..)的问题
- 寻求SELECT的写法?
- 如何用PL/SQL语句把一个数据表LONG数据类型的数据转到另一张表的LONG字段中去?
- oracle :ORA-01089: immediate shutdown in progress - no operations are permitted
- jboss连接oracle时ocijdbc9.dll 访问被拒绝
- 分区表的分区依赖列可以改么?
--除24就转换成小时了啊
Select Rownum, to_date('2010-12-18 08', 'yyyy-mm-dd hh24:mi:ss')+(Rownum-1)/24 tm
from dual connect by rownum< = (to_date('2010-12-20 08', 'yyyy-mm-dd hh24:mi:ss')- to_date('2010-12-18 08', 'yyyy-mm-dd hh24:mi:ss'))*24 +1;
select to_char(sysdate,'yyyy-mm-dd hh24') from dual;
SQL> select sdt+(level-1)/24 dt
2 from (select to_date('2010-10-10 08','yyyy-mm-dd hh24') sdt,
3 to_date('2010-10-11 08','yyyy-mm-dd hh24') edt
4 from dual)
5 connect by level <(edt-sdt)*24+2
6 /
DT
-------------
2010-10-10 08
2010-10-10 09
2010-10-10 10
2010-10-10 11
2010-10-10 12
2010-10-10 13
2010-10-10 14
2010-10-10 15
2010-10-10 16
2010-10-10 17
2010-10-10 18
2010-10-10 19
2010-10-10 20
2010-10-10 21
2010-10-10 22
2010-10-10 23
2010-10-11 00
2010-10-11 01
2010-10-11 02
2010-10-11 03
2010-10-11 04
2010-10-11 05
2010-10-11 06
2010-10-11 07
2010-10-11 0825 rows selected.SQL>
Select Rownum, to_date('2010-12-18 08', 'yyyy-mm-dd hh24:mi:ss')+(Rownum-1)/24 tm
from dual connect by rownum< = (to_date('2010-12-20 08', 'yyyy-mm-dd hh24:mi:ss')- to_date……刚好我也发现了 哎