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 |
|
MarkS
Starting Member
1 Post |
Posted - 2002-03-07 : 18:52:59
|
| HelloHere is what I am looking for. I have a database where there are two fields: "connect_date" and "disconnect_date" What I am trying to do is to find records that had a "connect_date" in specific range (say 11-1-01 to 11-30-01) and now I need to see if any of those accounts were "disconnect_date" within 60 days of "connect_date"Any help would be appreciated.We are running SQL 7.0 in case if you need this info. |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-03-07 : 19:10:43
|
| select * from tablewhere connect_date between @begindate AND @enddateAND disconnect_date <= dateadd(dd, 60, connect_date)That should do it. Of course you'll need to declare those params, and pass them into your stored proc, but I'm sure you have that much of the SP.Michael |
 |
|
|
fisherman_jake
Slave to the Almighty Yak
159 Posts |
Posted - 2002-03-07 : 19:23:11
|
| Just a little bit of a spin-off from Mick's solution.select * from tablewhere connect_date between @begindate AND @enddateAND datediff(dd, connect_date, disconnect_date) <= 60But I think Mick's solution will be faster if you have an index on (connect_date, disconnect_date). I think my solution will only need an index on (connect_date).==================================================Do not argue with IDIOTS. They will take you down to their level and BEAT you with experience.Master Fisherman |
 |
|
|
|
|
|