Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
datetime query
datetime query
Rate Topic
Display Mode
Topic Options
Author
Message
forum member
forum member
Posted Thursday, August 20, 2009 1:01 AM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, September 01, 2011 10:58 AM
Points: 76,
Visits: 906
Hi,
Need some help on the query,I have some problem writing a query for starttime falling between a range
select * from table where starttime between @starttime and @endtime
if here @starttime=20/08/2009 5:00:00.000 and @endtime=20/08/2009 10:00:00.000
by applying above start and endtime i also get the records from which start after 10:00:00.000
for example i get returned records whose start time is 20/08/2009 10:00:00
to resolve this i have used the below but i think this is not better way to do
select * from table where starttime between @starttime and @starttime and
endtime between @endtime and @endtime
Please help with this
Thanks
Post #774029
Dave Ballantyne
Dave Ballantyne
Posted Thursday, August 20, 2009 1:13 AM
SSCommitted
Group: General Forum Members
Last Login: Friday, May 10, 2013 4:07 PM
Points: 1,943,
Visits: 8,227
between does greater than or equal to and less than or equal to , so from what you've said ,"returned records whose start time is 20/08/2009 10:00:00", SQL seems to be returning the right data.
Can you provide a script that emulates your issue ?
Clear Sky SQL
My Blog
Kent user group
Post #774037
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.