我最近遇到了这个:
SELECT
'Y',
ltrim(rtrim(upper(Newly_Eligible)))
FROM Table
WHERE
Id = 1
AND
(Convert(datetime, Convert(varchar, GETDATE(),103),103)
BETWEEN
Convert(datetime,Convert(varchar, [Start_Date],103),103)
AND
Convert(datetime, Convert(varchar, [End_Date] ,103),103))
Start_Date
,End_Date
显然GETDATE()
是所有datetime
类型。为什么他会转换为 varchar 然后又返回?