hopefully a quick one this.
The below doesn’t work:
DECLARE @stringDate nvarchar(50)
SET @stringDate = '0001-01-01T12:00:00'
SELECT
@stringDate AS StringDate,
CONVERT(datetime, @stringDate, 126) AS ConvertedDate
Produces the error: The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
What’s the simplest way of achieving the conversion?
Thanks
Type
Datetimedoes not support the year 0001. Supported range is 1753 to 9999.As a workaround you can use type
DateTime2instead