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
 Script Library
 time compare with regular sql

Author  Topic 

sql_angel
Starting Member

2 Posts

Posted - 2011-07-25 : 12:55:41
Hi, I just wonder if there is any way to compare time in regular sql?
i need to do a select query that returns all entries that are not older than 7 days.

thank you,

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-25 : 12:59:10
[code]select * from yourtable where youdatefield > DATEADD(dd,DATEDIFF(dd,0,GETDATE()),-7)[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql_angel
Starting Member

2 Posts

Posted - 2011-07-25 : 14:03:52
thank you, visakh16
that's what exactly i need
Go to Top of Page
   

- Advertisement -