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
 Records greater than 30 days

Author  Topic 

Damian39
Starting Member

33 Posts

Posted - 2014-09-10 : 22:59:39
Hello all,
I have a query pulling all records with a disconnect date and a transaction date. However, I would like to retrieve any records that have a transaction date greater than 30 days from the disconnect date. I have been unable to figure out the correct formula to use. I think I need to use the datediff function in SQL, but I've never really used this function before. Any and all help is greatly appreciated. Thanks



Damian

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-09-11 : 00:44:47
SELECT * FROM dbo.Table1 WHERE Col1 < DATEADD(DAY, -30, GETDATE());


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

Damian39
Starting Member

33 Posts

Posted - 2014-09-11 : 12:01:43
Thank you for the reply Swepeso. Wouldn't using the getdate function within the formula calculate based on today's date rather than the date values within the tables I'm querying?

Damian
Go to Top of Page
   

- Advertisement -