Home > Enterprise >  How can I delete record based on date?
How can I delete record based on date?

Time:11-03

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.

CodePudding user response:

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'
  • Related