"HAVING" clause. I find the designer easier to read at some points, but I
do know what you're saying. My question is, why would the results change,
so I thought that would be as good a way as any to handle it. What is the
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:O%23H4P9hfHHA.5052@TK2MSFTNGP06.phx.gbl...
> "Rico" <me@you.com> wrote in message news:1DTTh.34$VF5.16@edtnps82...
>>I have some SQL with the following line in it;
>>
>> WHERE CONVERT(varchar(8), dbo.tblAppointments.fldAppointmentDate, 112)
>> BETWEEN CONVERT(varchar(8), CONVERT(Datetime, '4/2/2007'), 112) AND
>> CONVERT(varchar(8), CONVERT(Datetime, '4/3/2007'), 112)
>>
>> When I leave this as a where statement I get nothing when I execute the
>> SQL. When I change the WHERE to a Group By in the Diagram pane, I get the
>> two rows that are the expected result. I have two questions really, 1).
>> can anyone give me insite on why this is happening and 2) if there is a
>> reason for this strange behavour, is there any way I can get the expected
>> result without returning a row for each AppointmentDate (supposed to
>> only show clients).
>>
>> Any help would be greatly appreciated.
>>
>> Thank You!
>> Rick
>>
>>
>
> Exactly what did you use in the GROUP BY clause? GROUP BY doesn't perform
> any restriction like WHERE does so there is no direct comparison.
>
> Assuming fldAppointmentDate is a DATETIME or SMALLDATETIME column then
> your WHERE expression is very ill-constructed. In a range query like this
> it's important to avoid unnecessary type conversions. It's also better to
> rely on ISO date formats rather than regional formats. Example:
>
> ... WHERE fldAppointmentDate >= '20070402'
> AND fldAppointmentDate < '20070404'
>
> Avoid the Query Design interface if you can because it will mangle your
> code and anyway has far too many limitations. As for the "fld" and "tbl"
> prefixes... maybe the less said about that the better :-(
>
> Hope this helps.
>
> --
> David Portas, SQL Server MVP
>
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
>
> SQL Server Books Online:
>
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>
>
>
>
>
>