如何使用 where 子句过滤日期时间列
How can i filter a datetime column using a where clause
我需要筛选一个名为 Departure 的日期时间列。
我需要过滤器 return 所有价格 <=100 且出发日期介于 2105-03-14 和 2015-03-17 之间且这些日期的出发时间从下午 1 点开始。
我尝试了下面的代码。联接工作正常,但 where 子句是问题所在。谁能帮忙。
Select Destination,Departure,Price
From PriceTable as p
Join Routes as r
On p.RouteID = r.ID
Join Destinations as d
On d.Airport_ICAO_Code = r.Airport_ICAO_Code
Where (Price <= 100) And (Departure between '2015-03-14' and '2015-03-17' >= '13:00:00')
Order by Price Asc
xx:xx:xx
一段时间后过滤记录的语法不正确。试试这个 where
子句
.....
.....
WHERE Price <= 100
AND Departure BETWEEN '2015-03-14' AND '2015-03-17'
AND CONVERT(TIME, Departure) >= '13:00:00'
.....
我需要筛选一个名为 Departure 的日期时间列。
我需要过滤器 return 所有价格 <=100 且出发日期介于 2105-03-14 和 2015-03-17 之间且这些日期的出发时间从下午 1 点开始。
我尝试了下面的代码。联接工作正常,但 where 子句是问题所在。谁能帮忙。
Select Destination,Departure,Price
From PriceTable as p
Join Routes as r
On p.RouteID = r.ID
Join Destinations as d
On d.Airport_ICAO_Code = r.Airport_ICAO_Code
Where (Price <= 100) And (Departure between '2015-03-14' and '2015-03-17' >= '13:00:00')
Order by Price Asc
xx:xx:xx
一段时间后过滤记录的语法不正确。试试这个 where
子句
.....
.....
WHERE Price <= 100
AND Departure BETWEEN '2015-03-14' AND '2015-03-17'
AND CONVERT(TIME, Departure) >= '13:00:00'
.....