I want to look for all records within a table that has date column for a specific date, at the moment I am trying this query,
SELECT *
FROM Table_ABC
WHERE DateCreated CONTAINS 24/10/2012
But its not working
I want to look for all records within a table that has date column for a specific date, at the moment I am trying this query,
SELECT *
FROM Table_ABC
WHERE DateCreated CONTAINS 24/10/2012
But its not working
If the DateCreated column is a DATETIME type, you should try:
SELECT *
FROM Table_ABC
WHERE YEAR(DateCreated) = 2012
AND MONTH(DateCreated) = 10
AND DAY(DateCreated) = 24
or simply
SELECT *
FROM Table_ABC
WHERE DATE(DateCreated) = "2012-10-24"
Try:
Select * from Table_ABC where DateCreated between '24/10/2012 HH:MM:SS' and '24/10/2012 HH:MM:SS'
Changes hours minutes and seconds to be what you want it to be and it's usually in 24 hour time.
I would recommend the following statement:
SELECT *
FROM Table_ABC
WHERE CONVERT(DATE, DateCreated) = '2012-10-24'
Reference for CONVERT: https://docs.microsoft.com/sql/t-sql/functions/cast-and-convert-transact-sql
In case it's helpful, this adds a wildcard:
SELECT *
FROM Table_ABC
WHERE CONVERT(DATE, DateCreated) LIKE '%2012-10-24%'