Page 1 of 1

Delete query with respect to date only

Posted: Sat Aug 01, 2009 2:05 am
by habib009pk
Hi Friend

I am facing a problem i have different records with same date but with different times. The feilds having datatype datetime. Now i want to delete all the records with same date only..
but when i am running this query:

DELETE FROM auct_lots_full WHERE lot_date='2009-07-31';

so this query doesn't gave me any positve result..

Please Help me regarding this query

Thanks And Regards

Re: Delete query with respect to date only

Posted: Sat Aug 01, 2009 8:49 pm
by John Cartwright
You will need to convert the datetime value to a date value, I.e.,

Code: Select all

... WHERE DATE(lot_date) = '2009-07-31'
Otherwise, treat the date as a range, I.e.,

Code: Select all

... WHERE lot_date BETWEEN '2009-07-31 00:00:00' AND '2009-07-31 23:59:59'