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
 DateTime Greater Than 14 Days

Author  Topic 

cnbhold
Starting Member

43 Posts

Posted - 2011-05-23 : 10:56:37
I have a table called Migration that logs the datetime when a user was sent an email. The user has 14 days to respond. How do I create a query that will show me all requests that are 14 days old?

Table Structure

TRK_Num varchar(10)
NodeName varchar(100)
FullName varchar(100)
COMM1 datetime

Sample Data

1001 HP101232 James Smith 5/1/2011 10:52:10 AM
1002 HP154789 Angela Davis 5/10/2011 12:30:15 PM
1003 HP012987 Henry Douglas 5/15/2011 2:15:45 PM

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-05-23 : 11:16:40
where comm1 < dateadd(dd,-14,getdate()) is the simplest method.

If you want the date excluding the time, the dateadd(dd,0,datediff(dd,0,getdate()-14)) or similar.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-05-23 : 11:17:06
WHERE comm1 >= dateadd(day,datediff(day,14,getdate()),0)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

cnbhold
Starting Member

43 Posts

Posted - 2011-05-23 : 12:29:54
Thanks for the help.
Go to Top of Page
   

- Advertisement -