数据表里面有DateTime字段, 日期和时间同时进行时间查询应该怎么做?
数据表里面有DateTime字段, 日期和时间同时进行时间查询应该怎么做?
有表
字段名称 字段类型
GUID VARCHAR(50)
str_DateTime DATETIME
想实现查询2005年5月1日-2006年1月1日
时间在18:00到19:00的所有GUID
应该怎么做呀?
谢谢
问题点数:100、回复次数:7Top
1 楼lsqkeke(可可)回复于 2006-03-03 15:03:49 得分 25
select * from tb
where (convert(char(10),str_DateTime,120) between '2005-05-01' and '2006-01-01')
and (convert(char(5),str_DateTime,108) between '18:00' and '19:00')Top
2 楼share1011(不知道)回复于 2006-03-03 15:08:16 得分 25
select GUID from 表 where str_DateTime between '2005-5-1'and '2006-1-1' and substring(convert(char(19),str_DateTime121),12,5) between '18:00'and '19:00'Top
3 楼share1011(不知道)回复于 2006-03-03 15:13:05 得分 0
select GUID from 表 where (convert(char(10),str_DateTime,121) between '2005-5-1'and '2006-1-1' and substring(convert(char(19),str_DateTime121),12,5) between '18:00'and '19:00'
Top
4 楼libin_ftsafe(子陌红尘:TS for Banking Card)回复于 2006-03-03 15:14:58 得分 25
select
*
from
表
where
convert(char(10),str_DateTime,120) between '2005-05-01' and '2006-01-01'
and
convert(char(5),str_DateTime,114) between '18:00' and '19:00'
Top
5 楼zhouhaihe()回复于 2006-03-03 15:19:19 得分 25
select * from tb
where (str_DateTime between '2005-05-01' and '2006-01-01')
and (convert(char(5),str_DateTime,108) between '18:00' and '19:00')
Top
6 楼jhtchina(学习构架设计)回复于 2006-03-03 15:53:14 得分 0
谢谢Top
7 楼geniusli(纠级天使)回复于 2006-03-03 16:24:19 得分 0
select tablename.*
from tablename
where (convert(char(10),str_DateTime,120)
between '2005-05-01' and '2006-01-01')
and (convert(char(5),str_DateTime,108) between '18:00' and '19:00')Top




