View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 09:26 AM
Captain Paralytic
 
Posts: n/a
Default Re: date delete query

On 20 Mar, 10:49, "roohbir" <ros...@gmail.com> wrote:
> Hello,
> I have a table called DateOfBirth which has dates in the format:
> '2001-08-23 00:00:00'.
> I want to make a query which deletes the dates after the year 1996.
> Would be really thankful if someone helps me with this query.
> Thanks
> Ros


Do you mean "deletes records where the column 'colname' has dates
after the year 1996"?#

If so, assuming that the column is a date column then
DELETE FROM `DateOfBirth` WHERE YEAR(`colname`) > 1996

If it is a text column then
DELETE FROM `DateOfBirth` WHERE LEFT(`colname`, 4) > '1996'

Reply With Quote