Re: [SQL ] 請教MSSQL datetime只取出時間做篩選

看板Database作者 (沒有風,雲怎麼飄?)時間14年前 (2010/08/01 00:41), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《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
文章代碼(AID): #1CL59COW (Database)
討論串 (同標題文章)
文章代碼(AID): #1CL59COW (Database)