Re: SQL Between Dates



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

.



Relevant Pages

  • Re: Linking tables access - sql server 2005
    ... Another advantage of this method is that you don't need an ODBC setting on the local computer, ... Create a linked table to SQL Server without using a DSN ... Name of the table that you are linking to on the SQL Server database ... Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Cannot Generate SSPI Context - help
    ... I have used the following DSN-less string: ... Microsoft OLE DB Provider for SQL Server error '80004005' ... When a connection is "trusted," it means ... > How would one connect to a remote SQL Server using Windows authen? ...
    (microsoft.public.inetserver.asp.db)
  • Re: INSERT Query problem with Quotes & Apostrophes
    ... I've got front-ends that go against both Jet and SQL Server databases. ... InputText As String, _ ... >> Delimiter, Delimiter & Delimiter) ... dDateTime, ...
    (microsoft.public.access.modulesdaovba)
  • Re: ADO.NET 2.0 saving single space to SQL?
    ... It is code someone else wrote quite some time ago and all of the string ... Hitchhiker's Guide to Visual Studio and SQL Server ... and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: using OpenXML in T-sql?
    ... am not the most senior person in sql server programming, ... especially xml stuff. ... style string in place of an array without the additional ... >delimited strings and opts for the xml string instead. ...
    (microsoft.public.sqlserver.programming)