Task: convert a DateTme
column (cast as varchar) that may contain 1753-01-01
to an empty string.
What is the most efficient way to do this in T-SQL?
For example, if I use:
SELECT
LEFT(CONVERT(VARCHAR, DateCol1, 120), 10)
FROM
ourDatabase.dbo.ourTable
How can I efficiently change any row containing '1753-01-01' to an empty string?
NOTE: it appears the value '1753-01-01' really does appear in the database table; it sometimes is returned where there are nulls. One can even do a datepart yy and get 1753, so it is NOT ‘null’ in the ordinary sense.
Please see also:
What is the significance of 1/1/1753 in SQL Server?
for background on this specific date.
Also, please see: {general discussion of Datetime to varchar conversion}:
How to convert DateTime to VarChar
This is for Microsoft SQL Server 2014 using SSMS 14.0.17