SQL Server 7.0
The following SQL:
SELECT TOP 100 PERCENT fldTSRID, fldDateEntered
FROM tblTSRs WITH (NOLOCK)
WHERE ((fldDateEntere d >= CONVERT(DATETIM E, '2003-11-21 00:00:00',
102))
AND
(fldDateEntered <= CONVERT(DATETIM E, '2003-11-23 23:59:59', 102)))
returns this record:
fldTSRID: 4
fldDateEntered: 24/11/2003
Hello? How is 24/11/2003 <= '2003-11-23 23:59:59'?
I tried decrementing the second predicate by seconds:
(fldDateEntered <= CONVERT(DATETIM E, '2003-11-23 23:59:30', 102)))
returns the record, but
(fldDateEntered <= CONVERT(DATETIM E, '2003-11-23 23:59:29', 102)))
does NOT.
What is happening here?
Edward
=============== =============
TABLE DEFINITION:
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[FK_tblTSRNotes_ tblTSRs]') and OBJECTPROPERTY( id,
N'IsForeignKey' ) = 1)
ALTER TABLE [dbo].[tblTSRNotes] DROP CONSTRAINT FK_tblTSRNotes_ tblTSRs
GO
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[tblTSRs]') and OBJECTPROPERTY( id, N'IsUserTable') =
1)
drop table [dbo].[tblTSRs]
GO
CREATE TABLE [dbo].[tblTSRs] (
[fldTSRID] [int] IDENTITY (1, 1) NOT NULL ,
[fldDealerID] [int] NOT NULL ,
[fldWorkshopGrou pID] [int] NULL ,
[fldSubjectID] [int] NULL ,
[fldReasonID] [int] NULL ,
[fldFaultID] [int] NULL ,
[fldContactID] [int] NULL ,
[fldMileage] [int] NULL ,
[fldFirstFailure] [smalldatetime] NULL ,
[fldNumberOfFail ures] [int] NULL ,
[fldTSRPriorityI D] [int] NULL ,
[fldTSRStatusID] [int] NULL ,
[fldAttachedFile Path] [char] (255) NULL ,
[fldFileAttached] [smallint] NOT NULL ,
[fldFaultDescrip tion] [ntext] NULL ,
[fldFaultRectifi cation] [ntext] NULL ,
[fldEmergency] [int] NOT NULL ,
[fldDateEntered] [smalldatetime] NOT NULL ,
[fldEnteredBy] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
The following SQL:
SELECT TOP 100 PERCENT fldTSRID, fldDateEntered
FROM tblTSRs WITH (NOLOCK)
WHERE ((fldDateEntere d >= CONVERT(DATETIM E, '2003-11-21 00:00:00',
102))
AND
(fldDateEntered <= CONVERT(DATETIM E, '2003-11-23 23:59:59', 102)))
returns this record:
fldTSRID: 4
fldDateEntered: 24/11/2003
Hello? How is 24/11/2003 <= '2003-11-23 23:59:59'?
I tried decrementing the second predicate by seconds:
(fldDateEntered <= CONVERT(DATETIM E, '2003-11-23 23:59:30', 102)))
returns the record, but
(fldDateEntered <= CONVERT(DATETIM E, '2003-11-23 23:59:29', 102)))
does NOT.
What is happening here?
Edward
=============== =============
TABLE DEFINITION:
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[FK_tblTSRNotes_ tblTSRs]') and OBJECTPROPERTY( id,
N'IsForeignKey' ) = 1)
ALTER TABLE [dbo].[tblTSRNotes] DROP CONSTRAINT FK_tblTSRNotes_ tblTSRs
GO
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[tblTSRs]') and OBJECTPROPERTY( id, N'IsUserTable') =
1)
drop table [dbo].[tblTSRs]
GO
CREATE TABLE [dbo].[tblTSRs] (
[fldTSRID] [int] IDENTITY (1, 1) NOT NULL ,
[fldDealerID] [int] NOT NULL ,
[fldWorkshopGrou pID] [int] NULL ,
[fldSubjectID] [int] NULL ,
[fldReasonID] [int] NULL ,
[fldFaultID] [int] NULL ,
[fldContactID] [int] NULL ,
[fldMileage] [int] NULL ,
[fldFirstFailure] [smalldatetime] NULL ,
[fldNumberOfFail ures] [int] NULL ,
[fldTSRPriorityI D] [int] NULL ,
[fldTSRStatusID] [int] NULL ,
[fldAttachedFile Path] [char] (255) NULL ,
[fldFileAttached] [smallint] NOT NULL ,
[fldFaultDescrip tion] [ntext] NULL ,
[fldFaultRectifi cation] [ntext] NULL ,
[fldEmergency] [int] NOT NULL ,
[fldDateEntered] [smalldatetime] NOT NULL ,
[fldEnteredBy] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Comment