Reputation: 11
How do I delete by month name instead of date number?
I would like to use 'April' instead of '04'
This is as far as i have gotten, but it still does not work.
DELETE *
FROM myTable
WHERE CONVERT(DATE, myColumn) LIKE 'April'
Upvotes: 1
Views: 39
Reputation: 11
You can use function DATENAME
, see documentation here: https://msdn.microsoft.com/en-us/library/ms174395.aspx
In your case, it would be:
DELETE FROM MyTable WHERE DATENAME(MONTH,myColumn) LIKE 'April'
Upvotes: 1
Reputation: 14341
DELETE
FROM
MyTable
WHERE
DATENAME(MONTH,myColumn) LIKE 'April'
since SQL-SERVER 2008 you can use DATENAME()
function to extract it from a date. I personally would still prefer the integers but since you asked....
https://msdn.microsoft.com/en-us/library/ms174395.aspx
Upvotes: 1