sql server判断datetime类型的数据:
如果2023-09-06 13:28:09.000 < 2023-09-06 09:00:0.000,日期减一,输出年月日:2023-09-05
如果
2023-09-06 13:28:09.000 > 2023-09-06 09:00:0.000,输出年月日:2023-09-06
假设
2023-09-06 13:28:09.000 字段A
2023-09-06 09:00:0.000 字段B
SELECT (CASE WHEN 字段A<字段B THEN convert(nvarchar(10),DATEADD(day,-1,字段A),120) ELSE convert(nvarchar(10),字段A,120) END) [NEW_]