all groups > sql server programming > september 2004 >
You're in the

sql server programming

group:

Comparing Times



RE: Comparing Times payyans
9/6/2004 5:41:02 PM
sql server programming: Hi Simon,
Probably, Select * from charge_rates where {t '10:30:00'} between fromtime
and endtime
will resolve your problem.
Thanks,
payyans

[quoted text, click to view]
Comparing Times Simon Harris
9/6/2004 11:17:29 PM
Hi All,

I have a table with three columns - price,fromtime and totime

The fromtime/totime columns are date/time format - I have stored just a time
in them - e.g. 8:30 / 10:30

I am trying to run queries based on time alone (Not dates) but do not seems
to get any results back.

e.g.

Select * from charge_rates where '10:30' between fromtime and endtime
(10:30 being a user defined value)

I have also tried:
Select * from charge_rates whereconvert(datetime,'10:30',114) between
fromtime and endtime
and...
Select * from charge_rates whereconvert(datetime,'10:30',104) between
fromtime and endtime

None seem to return results I need. A collegue suggested using datepart to
compare the hour, problem is we dont know what the minute is...e.g: can be
10:15, 10:30...and so on.

Any help will be appreciated! :)

Regards,
Simon.

--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!

Re: Comparing Times Anith Sen
9/6/2004 11:39:01 PM
Can you post your table structures and sample data for a few rows along with
the results you'd expect from your query? That would help others in
understanding your requirements better & repro the problem better. For
details refer to: www.aspfaq.com/5006

--
Anith

AddThis Social Bookmark Button