Reputation: 1309
Here is the sample data
How can I remove the date if the date is between the date range below?
The result should only display
21 Jan 2015
Upvotes: 0
Views: 492
Reputation: 101
DELETE FROM tableName WHERE date BETWEEN '01/26/2015' AND '01/27/2015'
Upvotes: 0
Reputation: 352
Try this format:
DELETE FROM table WHERE date = '2015-01-21'
or
DELETE FROM table WHERE date > '2015-01-20' AND date < '2015-01-22';
Maybe the date is not exactly '2015-01-21'.
Upvotes: 0
Reputation: 13971
Use between
to delete rows between the given dates :
DELETE FROM date1
WHERE (date BETWEEN '01/26/2015' AND '01/27/2015')
Now values other than 21st Jan 2015 will get deleted :
use select
query to view your result.
Output :01/21/2015
Upvotes: 1
Reputation: 5743
If you just want to display, use NOT EXISTS()
in the select
SELECT Date FROM Dates d
WHERE NOT EXISTS(SELECT * FROM DateRange WHERE d.Date BETWEEN StartDate AND EndDate)
If you need to delete the records
DELETE FROM Dates d
WHERE EXISTS(SELECT * FROM DateRange WHERE d.Date BETWEEN StartDate AND EndDate)
Upvotes: 0