DELETE FROM BIZ
WHERE [Orgnl_Cmpltn_Date]
BETWEEN '2014-02-31' AND '2014-04-01'
This is the DELETE
statement I wrote. There is an error that says:
Conversion failed when converting date and/or time from character string.
I know I have to write the correct date format, but I am not sure how that goes.
This question has not been answered elsewhere because the answers I saw did not specify date format (in the context that I am asking for)
From which table do you want to delete the records? you just need to replace the select-command with an delete-command, followed by the table to delete the data from. Then remove the order-by-clause and that's it.
The SQL BETWEEN Operator The values can be numbers, text, or dates. The BETWEEN operator is inclusive: begin and end values are included.
SELECT * FROM PERSONAL WHERE BIRTH_DATE_TIME BETWEEN '2000-01-01 00:00:00' AND '2002-09-18 12:00:00';
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. You need separators for the date like a “/”, a “.” or a “-“. We use substring to concatenate the “-” to use an acceptable date format and then we use the CONVERT function to convert the characters to sql date.
You wrote 31st of February... Maybe..... that date doesn't exists.
DELETE FROM BIZ
WHERE [Orgnl_Cmpltn_Date]
BETWEEN '2014-02-28' AND '2014-04-01'
For a general idea of convert date:
DELETE FROM BIZ
WHERE [Orgnl_Cmpltn_Date]
BETWEEN CONVERT(date,'2014.02.28',102) and CONVERT(date,'2014.04.01',102)
Here you can find the complete list of values for third parameter of CONVERT
https://msdn.microsoft.com/en-us/library/ms187928.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With