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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 >= and <= signs in Query?????

Author  Topic 

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-08-26 : 02:18:50
Hello All,
I have to compare date in my query and my query is like

select * from ABC
where
Date1>=(Select DateColumn from Table2 on MyCondition)
and
Date2<= (Select DateColumn from Table2 on MyCondition)

But the above mentioned query is not working properly.
Can I Use >= and <= in query?

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-08-26 : 02:34:27
Query posted by you gives error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'on'.
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'on'.

Please provide table structure with sample data and desired output.
Go to Top of Page

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-08-26 : 02:38:21
Actually this is not exact query , this is structure of query :)

I just want to compare a date with in my query and wants to use >= and <= signs,
but when i use >= sign , query is executed OK but results are fetched by > sign only and = sign is ignored.

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-26 : 02:47:58
select * from ABC
where
Date1>=(Select DateColumn from Table2 on where MyCondition)
and
Date2<= (Select DateColumn from Table2 on where MyCondition)


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-08-26 : 02:53:15
Go through these links:

http://weblogs.sqlteam.com/jeffs/archive/2004/12/02/2954.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50569


Go to Top of Page
   

- Advertisement -