从日期获取年,月或日

参考:

 

DECLARE @D DATETIME = GETDATE()

SELECT DATEPART(YEAR,@D) AS [YEAR], DATEPART(MONTH,@D) AS [MONTH], DATEPART(DAY,@D) AS [DAY] 

SELECT YEAR(@D) AS [YEAR], MONTH(@D) AS [MONTH], DAY(@D) AS [DAY]
Source Code

 

posted @ 2020-02-21 08:24  Insus.NET  阅读(349)  评论(0编辑  收藏  举报