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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL time question

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2009-01-29 : 12:09:08
I have a shopping cart table that has a datetime field in it. I want to select all records that do not include the time plus 10 minutes. So if the entry is within that 10 minutes window, I do not want to include it in the records returned

Dave
Helixpoint Web Development
http://www.helixpoint.com

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-29 : 12:11:39
did you meant this?

select * from table where ABS(DATEDIFF(mm,datefield,GETDATE())>10
Go to Top of Page

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2009-01-29 : 12:16:01
Incorrect syntax near '>'.

Dave
Helixpoint Web Development
http://www.helixpoint.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-29 : 12:23:18
missed a braces

select * from table where ABS(DATEDIFF(mm,datefield,GETDATE()))>10
Go to Top of Page

tonymorell10
Yak Posting Veteran

90 Posts

Posted - 2009-01-29 : 12:39:02
Shouldn't that be

select * from table where ABS(DATEDIFF(mi,datefield,GETDATE()))>10
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-29 : 12:41:33
quote:
Originally posted by tonymorell10

Shouldn't that be

select * from table where ABS(DATEDIFF(mi,datefield,GETDATE()))>10



ah...yes...nice spot

or even

select * from table where ABS(DATEDIFF(n,datefield,GETDATE()))>10
Go to Top of Page
   

- Advertisement -