SQL 日期跟時間的欄位合併後的查詢

將日期跟時間的欄位合併後 存在temp
再用between做搜尋

with temp as
(
SELECT convert(char(11),Date)+convert(char(8),ImportTime) as DateTime,Symbol,Price
FROM     Stock WITH (nolock)
Where (Date between '2014-02-26' and '2014-02-27') and Symbol = '1101'
)

SELECT DateTime,Symbol,Price
from temp
Where DateTime BETWEEN '2014-02-26 10:00:00' AND '2014-02-27 11:00:00'
order by DateTime


留言

這個網誌中的熱門文章

R中Try and Catch的寫法

如何將DSM(NAS)變成Mail Server

使用VBA記錄股市每分鐘的交易記錄