Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with query datetime filter
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00745911
Message ID:
00745941
Views:
18
Kirk,

Datetime on SQL Server has a millisecond portion. Try
set @ttQueryFrom = '02/04/2002 00:00:00'
set @ttQueryTo   = '02/05/2002 00:00:00'
select begintime,endtime
 from meetings
 where deptID = @tiDeptID
  and  begintime >= @ttQueryFrom And begintime < @ttQueryTo
>I am having something wierd...probably me, but if I use the between clause in the where portion, I get zero results. I am trying this in the QA. If I do begintime >= @ttQueryFrom I get results, but if I do begintime between @ttQueryFrom and @ttQuery to it returns nothing and if I do begintime >= @ttQueryFrom and begintime < = @ttQueryTo I get no results.
>
>declare @tiDeptID int
>declare @ttQueryFrom datetime
>declare @ttQueryTo   datetime
>
>set @ttQueryFrom = '02/04/2002 00:00:00'
>set @ttQueryTo   = '02/04/2002 23:59:00'
>set @tiDeptID = 23
>
>
>select begintime,endtime
>from meetings
>where deptID = @tiDeptID
>and  begintime between @ttQueryFrom and @ttQueryTo
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform