作者jameswiki (没有风,云怎麽飘?)
站内Database
标题Re: [SQL ] 请教MSSQL datetime只取出时间做筛选
时间Sun Aug 1 00:41:45 2010
※ 引述《alen332l 看板: Database》之铭言:
: FROM 资料库
: where
: (timeT between '2010-03-01 07:00:00' and '2010-03-01 10:00:00')
: (timeT between '2010-03-02 07:00:00' and '2010-03-02 10:00:00')
: (timeT between '2010-03-03 07:00:00' and '2010-03-03 10:00:00')
: (timeT between '2010-03-04 07:00:00' and '2010-03-04 10:00:00')
: (timeT between '2010-03-05 07:00:00' and '2010-03-05 10:00:00')
: (timeT between '2010-03-06 07:00:00' and '2010-03-06 10:00:00')
: .
: .
SELECT *
FROM 资料库
where
year(timeT)=2010
and
month(timeT)=3
and
(
( datapart(hour,timeT)>=7 and datapart(hour,timeT)<=9)
or
(datapart(hour,timeT)=10
and
datapart(minute,timeT)=0
and
datapart(second,timeT)=0)
)
Enjoy~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 139.175.54.244