Monday, February 20, 2012

Problem with date in select statement

I use this statement to request a query from DB :

SELECT *
FROM Recipts
WHERE (StockCode = 1000100001 ) and (ReciptDate > 2002-1-1 )and (ReciptDate < 2003-1-1 )

I have a row in DB with these fields

(StockCode = 1000100001)
and
(ReciptDate = 2002-12-08 00:00:00.000)

but my query return no rows

why this happened !use single quotes around your date strings

where ... ReciptDate > '2002-01-01'
and ReciptDate < '2003-01-01'

rudy

No comments:

Post a Comment