Delete query with respect to date only

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
habib009pk
Forum Commoner
Posts: 43
Joined: Sun Jul 05, 2009 11:28 pm

Delete query with respect to date only

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Delete query with respect to date only

Post 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'
Post Reply