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 |
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2010-04-03 : 15:09:54
|
| In Database I've Two Date FieldsDate1 & Date2In my Query Parameters I've again Two Dates say d1 & d2I've to check if the same dates are exists in TableORIf D1 or D2 is in between dates of Date1 and Date2ExampleDate1=01/01/2010Date2=05/01/2010If D1=01/01/2010D2=05/01/2010Return FalseIf D1=02/01/2010D2=10/01/2010Return FalseIf D1=30/12/2009D2=03/01/2010Return FalseIf D1=06/01/2009D2=12/01/2010Return TrueActually I'm uploading data between two dates. Someone should not upload duplicate data.VB6/ASP.NET------------------------http://www.nehasoftec.com |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-04 : 02:14:04
|
| [code]INSERT INTO YourTable (Date1,Date2)SELECT @d1,@d2WHERE NOT EXISTS(SELECT 1 FROM YourTable WHERE @d1 BETWEEN Date1 AND Date2 OR @d2 BETWEEN Date1 AND Date2 )[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2010-04-04 : 21:55:50
|
quote: Originally posted by visakh16
INSERT INTO YourTable (Date1,Date2)SELECT @d1,@d2WHERE NOT EXISTS(SELECT 1 FROM YourTable WHERE @d1 BETWEEN Date1 AND Date2 OR @d2 BETWEEN Date1 AND Date2 ) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Thanx, I'm trying..VB6/ASP.NET------------------------http://www.nehasoftec.com |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-05 : 05:43:58
|
| Welcome..Let us know how you got on..------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|