Reputation: 1142
I got this query:
select IDS as data
from dbo.SKz
where dbo.SKz.DatSave >= 2008-12-20
and it works OK. But when I want query by hours and minutes:
select IDS as data
from dbo.SKz
where dbo.SKz.DatSave >= 2008-12-20 23:59:59
I get an error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '23'.
DatSave
is a datetime
column. Example from row = 2008-12-26 13:44:37.000
Where is the problem? Thank you.
Upvotes: 0
Views: 87
Reputation: 1271151
You need quotes. However, I would strongly recommend one of the two following:
select IDS as data
from dbo.SKz
where dbo.SKz.DatSave >= '2008-12-21'
or:
select IDS as data
from dbo.SKz
where dbo.SKz.DatSave >= dateadd(day, 1, '2008-12-20')
I am guessing that you really do not want date/time values that are one second before midnight.
Upvotes: 0
Reputation: 585
You have to put quotes around it.
select IDS as data from dbo.SKz WHERE dbo.SKz.DatSave>= '2008-12-20 23:59:59'
Upvotes: 4