|
Posted by Roy Harvey on 09/13/06 12:41
This is good news. It means the original versions were string
comparisons, not date comparisons. For whatever reason, SQL Server
apparently decided that the string were not dates, so it converted in
the other direction (datetime to string) and thus the strange results.
So all you have to do is use string formats that SQL Server recognizes
(as in the tests), or explicit conversions:
SELECT *
FROM SOL_Session
WHERE DateGiven >= CONVERT(datetime,'10/09/06',3)
AND DateGiven <= CONVERT(datetime,''13/09/06'',3)
Note that the third parameter indicates the specific format of the
string as dd/mm/yy. See the documentation on CONVERT for
alternatives.
Roy Harvey
Beacon Falls, CT
On Wed, 13 Sep 2006 13:29:44 +0100, "@sh" <spam@spam.com> wrote:
>Thanks again for your help here!!
>
>> SELECT *
>> FROM SOL_Session
>> WHERE DateGiven >= '10 Sep 2006'
>> AND DateGiven <= '13 Sep 2006'
>
>I get a listing of CORRECT results ;o)
>
>
>> SELECT *
>> FROM SOL_Session
>> WHERE DateGiven >= '20060910'
>> AND DateGiven <= '20060913'
>
>Another list of correct results - are these good or bad findings?
>
>Cheers, @sh
>
Navigation:
[Reply to this message]
|