Unix Technical Forum

date delete query

This is a discussion on date delete query within the MySQL forums, part of the Database Server Software category; --> Hello, I have a table called DateOfBirth which has dates in the format: '2001-08-23 00:00:00'. I want to make ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:26 AM
roohbir
 
Posts: n/a
Default date delete query

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10: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'

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:26 AM
roohbir
 
Posts: n/a
Default Re: date delete query

On Mar 20, 4:57 am, "Captain Paralytic" <paul_laut...@yahoo.com>
wrote:
> 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'


Thanks a lot Captain. It worked. The column is a date column.
Thanks again mate.
Roohbir

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com