SQL Server SELECT datetime< =当前日期&时间?

时间:2015-10-09 13:36:21

标签: sql datetime select compare

我有以下SELECT语句:

SELECT MAX([TargetUnits]) AS MaxUnits
FROM [TaktBoards].[dbo].[TargetPlot]
WHERE [TargetDate] <= GETDATE()

我的select语句忽略了日期时间字段TargetDate中的时间。当我运行select我得到13.05085时,无论我在哪一天运行它。这里的想法是,例如,当我在上午9:07运行选择时,我应该得到最大的TargetUnits为8.389831,但我得到13.05085。我做错了什么?

安迪

TargetUnits       TargetDate
0.9322034         2015-10-08 06:45:00.000
1.864407          2015-10-08 07:00:00.000
2.79661           2015-10-08 07:15:00.000
3.728814          2015-10-08 07:30:00.000
4.661017          2015-10-08 07:45:00.000
5.59322           2015-10-08 08:00:00.000
6.525424          2015-10-08 08:15:00.000
7.457627          2015-10-08 08:30:00.000
8.389831          2015-10-08 08:45:00.000
8.389831          2015-10-08 09:00:00.000
8.389831          2015-10-08 09:15:00.000
9.322034          2015-10-08 09:30:00.000
10.25424          2015-10-08 09:45:00.000
11.18644          2015-10-08 10:00:00.000
12.11864          2015-10-08 10:15:00.000
13.05085          2015-10-08 10:30:00.000

...

0 个答案:

没有答案