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
 Find items over time period

Author  Topic 

c123b456
Starting Member

2 Posts

Posted - 2008-07-02 : 06:47:41
Hello,

I am very new to sql having spent most of my time using access. I have a table called Cleaning with a field called Keyboards cleaned (which is a date). I am trying to set a query which will find keyboards that have not been cleaned for 3 or more months. After alot of searching i came up with the following:

Select [Keyboard Cleaned] AS Keyboard_Cleaned
From Cleaning
WHERE DatePart(MONTH, [Keyboard cleaned]) = DatePart(MONTH, GetDate()) - 3

I am running this on Visual Web Developer which allows sql statements to search access databases.

When i run this i get "undefined function 'GetData'in expression". I have tried a few different ways to get todays date which gives me various other errors.

Hope someone can help.

Thank you

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-02 : 06:52:50
GetData? sorry i cant see that word in your expression. Are you sure you've posted correct expression?
Go to Top of Page

c123b456
Starting Member

2 Posts

Posted - 2008-07-02 : 07:14:13
Sorry, i meant 'GetDate'
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-02 : 07:42:56

select keyboard,max([keyboard cleaned) as LastCleaned
from Cleaning
group by keyboard
having max([keyboard cleaned) <= DATEADD(month,-3,getdate())

Jim
Go to Top of Page
   

- Advertisement -