• umarrizwan (4/2/2013)


    issue is with varchar value 'z' in data ('2013-10-29 22:59:00Z) and you are converting it to datetime or datetime2.

    you can convert it after removing that value from data.

    use this.

    SELECT TOP 10 key_value

    ,convert(datetime2,PV.key_value) as DT2

    ,convert(datetime,CONVERT(DATETIME2, left(PV.key_value,19))) AS DT

    FROM parameter_value PV

    WHERE PV.datatype = 'D'

    and CONVERT(DATETIME,LEFT(PV.key_value,19)) BETWEEN GETDATE() and DATEADD(d, 10, GETDATE())

    The code I posted above works just fine in SQL Server 2008, even with the Z in the data.