当 regdate 列不为空或为空并且 regdate 超过 2 年时,喜欢将 regdate col 转换为 datetime。如果它为空,我喜欢将 regdate 插入为 1900-01-01。
id name regdate
555 bob 24/06/2013 00:00:00
556 tom 24/07/2013 00:00:00
557 jack 24/10/2008 00:00:00
558 susan 24/11/2009 00:00:00
559 emily
560 Mert
SELECT *, CAST(idate AS DATETIME) AS finalDate
INTO #tempFinal
FROM #tempA
WHERE CAST(idate AS DATETIME) < DATEADD(YEAR, -2, GETDATE())
OR idate IS NULL OR idate = ''