Click here to Skip to main content
16,016,184 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Check the date between 2 dates in another query?

SQL
Select * From TableName Where myDate Between (Select myFromDate,myTodate From AnotherTableName where id=3)
Posted
Comments
Herman<T>.Instance 12-Aug-14 3:53am    
You could have tried....
No
it is between....and.....

SQL
Select * From TableName Where myDate Between (Select myFromDate From AnotherTableName where id=3) and (Select myTodate From AnotherTableName where id=3)
 
Share this answer
 
Comments
_Asif_ 12-Aug-14 3:56am    
+5
TheWebDeveloper 12-Aug-14 3:59am    
My solution too I was going to post it +5
Hi,

Try this...

SQL
DECLARE @FrDate Datetime
DECLARE @ToDate Datetime

Select @FrDate=myFromDate, @ToDate=myTodate From AnotherTableName where id=3

Select * From TableName Where myDate Between @FrDate AND @ToDate



hope this will help you.


Cheers
 
Share this answer
 
Comments
Herman<T>.Instance 12-Aug-14 3:56am    
+5
Magic Wonder 12-Aug-14 3:58am    
thnx.
TheWebDeveloper 12-Aug-14 7:24am    
Not what I expected
Magic Wonder 12-Aug-14 7:46am    
I was not sure about your expectation.
TheWebDeveloper 13-Aug-14 4:21am    
Thnx for trying anyhow

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900