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
 General SQL Server Forums
 New to SQL Server Programming
 can we use <= and >= in sql

Author  Topic 

jdeepkumar@gmail.com
Starting Member

2 Posts

Posted - 2007-10-31 : 05:02:24
Hi
I have to find the stores between the time given value. for eg:

I have a table called store_hours where store_id, day, open_time and close_time are the columns.

a row containing sotre_id as 10004, day as Wednesday, open_time as 12:00 pm and close_time as 12:00 am

how can i find if store_id if the time given is 02:00 pm

like

select store_id, day, open_time, close_time from store_hour where open_time >= "02:00 pm" ans close_time <= "02:00 pm";

when i tried this query its throwing some error.
i need to kow how can i achieve this senario? help me please

thanks in advance

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-31 : 05:07:29
what is the datatype for open_time and close_time ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jdeepkumar@gmail.com
Starting Member

2 Posts

Posted - 2007-10-31 : 05:48:36
both are varchar
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-31 : 08:09:44
then you will have problem in comparing it. Convert to datetime before compare


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

IceDread
Yak Posting Veteran

66 Posts

Posted - 2007-10-31 : 08:24:06
Do a search on "time" or "compare" here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210

And you might find some info that might be handy ;)
Go to Top of Page

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-10-31 : 09:11:51
yes you can use the operators
<= and >=


create table rr(a varchar(50))
insert into rr values(123)
select * from rr where a<=130 and a>=120

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2007-10-31 : 09:55:33
hmm... i don't think that was the point actually

Em
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-01 : 03:09:20
quote:
Originally posted by arorarahul.0688

yes you can use the operators
<= and >=


create table rr(a varchar(50))
insert into rr values(123)
select * from rr where a<=130 and a>=120

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA


Read the question clearly

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -