sql server programming:
The jpg is pretty but it would be more beneficial to post the query here too
so that we don't have to (mis)type it.
select caldate, IO_ID. IO_DateUntil from calandar inner join Inout ON
--Note that you have an OR here so the resultant row probably matched this
line
--You probably need to rearrange your parenthesis
((caldate >= IO_Date - 1) and (IO_Afternoon = 0)) or
((caldate >= IO_Date) and (IO_Afternoon = 1))
and
(((caldate > IO_DateUntil) and (IO_AfternoonUntil = 1) and (IO_ACIDUntil <>
1)) or ((caldate < IO_DateUntil - 1)))
and (IO_ACID = 1)
where IO_SNID = 7
order by caldate
--
Hope this helps.
Dan Guzman
SQL Server MVP
[quoted text, click to view] "Stijn Verrept" <stijn@no_s.p.a.n.entrysoft.com> wrote in message
news:4001e058$0$1806$ba620e4c@news.skynet.be...
> I have a very simple query but it the results just don't seem to match.
> It seems to go wrong while doing datetime comparison.
>
> caldate and IO_DateUntil are smalldatetime's.
>
> I made a screenshot and highlighted the strange result and also the
> line of the query which should be FALSE and thus not give this result.
>
>
http://www.entrysoft.com/query.jpg >
> What am I missing here?
>
> --
> Kind regards,
>
> Stijn Verrept.