Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 comparing dates in SQL

Author  Topic 

constantinos
Starting Member

5 Posts

Posted - 2008-04-09 : 15:41:35
hi, i have a table with persons(babies) and their date of birth. I want to delete the persons above 6 months old can u plse tell me the query ?

delete
from babies
where ......

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-04-09 : 16:36:17
where BirthDate < dateadd(month, -6, getdate())

here's a page for you to study: http://msdn2.microsoft.com/en-us/library/ms186724.aspx


elsasoft.org
Go to Top of Page

constantinos
Starting Member

5 Posts

Posted - 2008-04-10 : 07:58:03
Thank u vevy much :)
Go to Top of Page

constantinos
Starting Member

5 Posts

Posted - 2008-04-10 : 08:32:34
I get the message "Undefined function 'getdate' in expression" whith this :

Delete
from Table1
where date_Of_birth < dateadd(month, -6,getdate());



Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-10 : 09:02:06
are you actually using SQL Server? ...or Access?

Em
Go to Top of Page

constantinos
Starting Member

5 Posts

Posted - 2008-04-10 : 09:17:04
access
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-10 : 09:19:15
ah... thought so from your error message

this is the sql server forum, so the answer you got was for sql server rather than access. think the function for current date is Date() ...? but not sure about dateadd. you may be better posting in the Access Forum

Em
Go to Top of Page

constantinos
Starting Member

5 Posts

Posted - 2008-04-10 : 09:28:28
yep i though it might work .. thanks anw :)
Go to Top of Page
   

- Advertisement -