好吧,您可以在比较两者之前将两个日期转换为任何格式,只需使用其中任何一个:运行此命令,您可以从中选择,确保在比较之前转换两个日期
Select
convert(varchar, GetDate(), 100) as '100 Conversion',
convert(varchar, GetDate(), 101) as '101 Conversion',
convert(varchar, GetDate(), 102) as '102 Conversion',
convert(varchar, GetDate(), 103) as '103 Conversion',
convert(varchar, GetDate(), 104) as '104 Conversion',
convert(varchar, GetDate(), 105) as '105 Conversion',
convert(varchar, GetDate(), 106) as '106 Conversion',
convert(varchar, GetDate(), 107) as '107 Conversion',
convert(varchar, GetDate(), 108) as '108 Conversion',
convert(varchar, GetDate(), 109) as '109 Conversion',
convert(varchar, GetDate(), 110) as '110 Conversion',
convert(varchar, GetDate(), 111) as '111 Conversion',
convert(varchar, GetDate(), 112) as '112 Conversion',
convert(varchar, GetDate(), 113) as '113 Conversion',
convert(varchar, GetDate(), 114) as '114 Conversion',
convert(varchar, GetDate(), 120) as '120 Conversion',
convert(varchar, GetDate(), 121) as '121 Conversion',
convert(varchar, GetDate(), 126) as '126 Conversion',
convert(varchar, GetDate(), 130) as '130 Conversion',
convert(varchar, GetDate(), 131) as '131 Conversion'
或者使用这个
select REPLACE(convert(varchar, GetDate(), 121),'-','/')