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
 select between getdate() and (getdate() - 2 min)

Author  Topic 

esambath
Yak Posting Veteran

89 Posts

Posted - 2009-08-10 : 11:27:35
Hi Friends,

I need to select the records which are all between the currentdatetime
and the 2 minutes before the currentdatetime.

please help me to get the query.

Thanks in advance

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-08-10 : 11:43:28
where date between GETDATE()and dateadd(mi,-2,getdate())
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-08-10 : 11:45:20
should'nt it be between MIN and MAX? instead of MAX and MIN?
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-08-10 : 11:45:42
[code]where datediff(mi,<urcolumn>,getdate()) <= 2[/code]
Go to Top of Page
   

- Advertisement -