My Question is,
I have a Column of type DateTime in SQL Table and it contains Values Like
2013-02-01 10:00:00.000
2013-01-27 16:00:00.000
2013-02-01 14:00:00.000
How can I get results with a Query if I only mention the Date in Where Clause like:
SELECT *
FROM tablename
WHERE columnName = '2013-02-01'
After executing this Query I want to have This Result
2013-02-01 10:00:00.000
2013-02-01 14:00:00.000
Kindly Help me in this.
Since your data is stored with times, you need to
Castthose to just Dates.Try this:
Depending on your SQL Server version (if it doesn’t support DATE data type), you can use this:
EDIT — As others have rightfully pointed out, you lose any performance gained from table indexing on that column in the above example. This should be what you’re looking for given a single input parameter (2013-01-01 in this case):
Good luck.