I am trying to fetch records from the table using the below sql query.
SELECT Code,Description FROM Table
WHERE ID= 1 AND FromDate >= '2010-02-14' AND ToDate <= '2012-03-14'
Even though records exists for this date, query returns nothing.
ID HID HCode HDescription FromDate ToDate
-------------------------------------------------------------------
1 3 H8 New Year 2012-03-14 12:38:00 2012-03-14 12:38:00
Please give me a suitable solution. Thanks for your time !!
FromDateandToDatefor the record withID=1?YYYY-MM-DDis safe fordatebut not fordatetime. Have a look here.Tis what makes that safe. Remove theTand it will fail.