以下是我在工作中经常要按某个年或月来分析数据的案例:
各以年,月,日分析数据
YEAR(mesReceive.xDateTime) AS N‘年‘, Right(100+Month(mesReceive.xDateTime),2) AS N‘月‘, DAY(mesReceive.xDateTime) AS N‘日‘,
以年-月分析数据
CONVERT(NVARCHAR(7),mesReceive.xDateTime ,120) AS N‘年-月‘,
以月-日分析数据
ISNULL(Right(100+Month(mesReceive.xDateTime),2) +‘-‘+ Right(100+DAY(mesReceive.xDateTime),2),‘‘) AS N‘月-日‘,
时间: 2024-10-10 09:05:16