Skip to content
Advertisement

How can I delete record based on date?

I have a set of data with DateTime type in SQL. I want to delete whatever data belong to a specific date for ex: 2021-11-02 21:07:52.663. if I have value like above I want to delete records using just date. 2021-11-02.

Advertisement

Answer

This will compare the date part of your datetime to the desired date:

DELETE
FROM
    MyTable mt
WHERE
    CAST(mt.MyDate AS DATE) = '2021-11-02'
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement