posts - 325,  comments - 25,  trackbacks - 0
表名:A
时间字段:ddatetime(datetime类型)

查询2003-2004年6月7日-7月8日数据。

select * from A where (extract(year from ddatetime) between 2003 and 2004)
and (extract(month from ddatetime) between 6 and 7)
and (extract(day from ddatetime) between 6 and 7)

extract只能取到日。小时,或者到秒,需要to_char。

查询2003-2004年6月7日-7月8日12时到20时数据。

select * from A where (extract(year from ddatetime) between 2003 and 2004)
and (extract(month from ddatetime) between 6 and 7)
and (extract(day from ddatetime) between 6 and 7) and (to_char(ddatetime,'HH24') between 12 and 20)

以上查询在oracle可运行。

posted on 2009-01-22 22:21 长春语林科技 阅读(1281) 评论(0)  编辑  收藏 所属分类: oracle

只有注册用户登录后才能发表评论。


网站导航:
 
<2009年1月>
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜