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
DateCreated 列が DATETIME 型の場合は、次のことを試してください。
SELECT *
FROM Table_ABC
WHERE YEAR(DateCreated) = 2012
AND MONTH(DateCreated) = 10
AND DAY(DateCreated) = 24
または単に
SELECT *
FROM Table_ABC
WHERE DATE(DateCreated) = "2012-10-24"
試す:
Select * from Table_ABC where DateCreated between '24/10/2012 HH:MM:SS' and '24/10/2012 HH:MM:SS'
時間、分、秒を希望どおりに変更します。通常は 24 時間です。
次のステートメントをお勧めします。
SELECT *
FROM Table_ABC
WHERE CONVERT(DATE, DateCreated) = '2012-10-24'
CONVERT のリファレンス: https://docs.microsoft.com/sql/t-sql/functions/cast-and-convert-transact-sql
役立つ場合は、ワイルドカードを追加します。
SELECT *
FROM Table_ABC
WHERE CONVERT(DATE, DateCreated) LIKE '%2012-10-24%'