This question is locked. New answers and comments are not allowed.
Data Acess Version: 2014.3.1027.1
Visual Studio Version: 2013 Ultimate Update 4
SQL Server: Microsoft SQL Server 2014 - 12.0.2000.8 (X64) Enterprise Edition (64-bit)
I'm facing some problems while reading data with Telerik Data Access when the table has DateTime2 columns and the user specifies a filter that is not in range (precision or date itself).
It appears that the component is always converting the data to DATETIME instead of DATETIME2, doing so, it loses precision and throws specific out of range exceptions handled by the DATETIME type.
I got the following query while tracing the problem in SQL Server:
SELECT a.[id] AS COL1, a.[datetime2_column] AS COL2 FROM [qa].[datetime2_issue] a WHERE a.[datetime2_column] >= CONVERT(DATETIME, '0001-01-01 00:00:00.000', 121) AND a.[datetime2_column] < CONVERT(DATETIME, '0001-01-02 00:00:00.000', 121) ORDER BY COL2
Which throws:
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
The correct should be:
,SELECT a.[id] AS COL1, a.[datetime2_column] AS COL2 FROM [qa].[datetime2_issue] a WHERE a.[datetime2_column] >= CONVERT(DATETIME2, '0001-01-01 00:00:00.000', 121) AND a.[datetime2_column] < CONVERT(DATETIME2, '0001-01-02 00:00:00.000', 121) ORDER BY COL2
Table and schema:
create schema qa
go
create table [qa].datetime2_issue
(
id int identity(1,1),
datetime2_column datetime2,
constraint pk_qa_datetime2_issue primary key (id)
)
Visual Studio Version: 2013 Ultimate Update 4
SQL Server: Microsoft SQL Server 2014 - 12.0.2000.8 (X64) Enterprise Edition (64-bit)
I'm facing some problems while reading data with Telerik Data Access when the table has DateTime2 columns and the user specifies a filter that is not in range (precision or date itself).
It appears that the component is always converting the data to DATETIME instead of DATETIME2, doing so, it loses precision and throws specific out of range exceptions handled by the DATETIME type.
I got the following query while tracing the problem in SQL Server:
SELECT a.[id] AS COL1, a.[datetime2_column] AS COL2 FROM [qa].[datetime2_issue] a WHERE a.[datetime2_column] >= CONVERT(DATETIME, '0001-01-01 00:00:00.000', 121) AND a.[datetime2_column] < CONVERT(DATETIME, '0001-01-02 00:00:00.000', 121) ORDER BY COL2
Which throws:
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
The correct should be:
,SELECT a.[id] AS COL1, a.[datetime2_column] AS COL2 FROM [qa].[datetime2_issue] a WHERE a.[datetime2_column] >= CONVERT(DATETIME2, '0001-01-01 00:00:00.000', 121) AND a.[datetime2_column] < CONVERT(DATETIME2, '0001-01-02 00:00:00.000', 121) ORDER BY COL2
Table and schema:
create schema qa
go
create table [qa].datetime2_issue
(
id int identity(1,1),
datetime2_column datetime2,
constraint pk_qa_datetime2_issue primary key (id)
)