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
 Date Query Criteria

Author  Topic 

ruci1225
Starting Member

3 Posts

Posted - 2013-04-26 : 13:41:59
In the database I have two date fields I am interested in
Lead Date
Record As od Date

In this scenerio I am trying to get all leads with lead date of x and return the line item where recordasofdate = Lead Date >= 14 and < 15 days.

this will allow me to see the status of the lead 14 days later for all the leads.


Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-04-26 : 13:54:04
What does this mean? "recordasofdate = Lead Date >= 14 and < 15 days"

It really helps if you can post sample data in a consumable format along with expected results. It makes it so we can run queries against your data and you get tested queries. Please see the links below:

http://www.sqlservercentral.com/articles/Best+Practices/61537/
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-29 : 00:35:49
asuuming its a typo and you meant date difference you can do like

...
WHERE recordasofdate > = DATEADD(dd,DATEDIFF(dd,0,LeadDate),14)
AND recordasofdate < DATEADD(dd,DATEDIFF(dd,0,LeadDate),15)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -