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.
| Author |
Topic |
|
groucho
Starting Member
2 Posts |
Posted - 2011-11-16 : 04:36:30
|
| I'm new to SQL and I was wondering if I could ask for some help from some of the users on here.Basically I have some data and I'm wanting SQL to look up everything logged and check the difference between the DateID and the DateCompleted where there is a difference of more that 21 days and return it for me.Can someone help write some code? The data in the table looks like the below.SSSC DateID DateCompleted MonthSBSC - CH 02/05/2011 19:45 15/09/2011 OctSBSC - KL 03/05/2011 11:02 18/10/2011 OctSBSC - KL 13/05/2011 12:27 29/09/2011 OctSBSC - CH 18/07/2011 08:08 20/09/2011 OctSBSC - CH 28/07/2011 07:17 20/09/2011 OctSBSC - MLA 02/08/2011 02:13 01/09/2011 OctSBSC - MLA 03/08/2011 16:10 01/09/2011 OctSBSC - MLA 03/08/2011 16:27 01/09/2011 OctSBSC - CH 08/08/2011 15:05 14/09/2011 OctSBSC - CH 10/08/2011 11:11 04/09/2011 OctSBSC - CH 11/08/2011 15:36 16/09/2011 OctSBSC - CH 12/08/2011 15:46 19/09/2011 OctSBSC - KL 15/08/2011 06:26 10/10/2011 Oct |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-16 : 04:43:07
|
| select * from tbl where datediff(dd,DateID,DateCompleted) > 21==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
groucho
Starting Member
2 Posts |
Posted - 2011-11-16 : 04:54:37
|
| Brilliant thanks.Is there anyway to incorporate a bit of code where it only searches for data where the DateCompleted is between 09/01/2011 and 11/01/2011?Thanks again for your help. |
 |
|
|
|
|
|