Re: SQL Between Dates
- From: Roy Harvey <roy_harvey@xxxxxxxx>
- Date: Wed, 13 Sep 2006 12:41:16 GMT
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@xxxxxxxx> 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
- References:
- SQL Between Dates
- From: @sh
- Re: SQL Between Dates
- From: Roy Harvey
- Re: SQL Between Dates
- From: @sh
- Re: SQL Between Dates
- From: @sh
- Re: SQL Between Dates
- From: Roy Harvey
- Re: SQL Between Dates
- From: @sh
- Re: SQL Between Dates
- From: Roy Harvey
- Re: SQL Between Dates
- From: @sh
- SQL Between Dates
- Prev by Date: Re: SQL Between Dates
- Next by Date: Re: SQL Between Dates
- Previous by thread: Re: SQL Between Dates
- Next by thread: Re: SQL Between Dates
- Index(es):
Relevant Pages
|