给定数字为269或456 ..如何使用单行sql函数获取年,月和日...如果可能的话?
由于
答案 0 :(得分:0)
怎么样
SELECT DATEADD(day, 0, 456)
好的,认真的怎么样
SELECT DATEADD(day, 0, 456) DateVal,
DATEDIFF(year,0,DATEADD(day, 0, 456)) YearPart,
DATEPART(month,DATEADD(day, 0, 456)) MonthPart,
DATENAME(month,DATEADD(day, 0, 456)) MonthNamePart,
DATEPART(day,DATEADD(day, 0, 456)) DayPart
输出
DateVal YearPart MonthPart MonthNamePart DayPart
1901-04-02 00:00:00.000 1 4 April 2