如何仅使用T-SQL并且不使用CASE语句来获取工作日名称知道工作日整数值?
例如,如果工作日整数值为2,那么我需要得到星期一'作为工作日的名字。
declare @currentDate as DATETIME;
set @currentDate = getdate();
SELECT DATEPART(dw, @currentDate) as WeekDayIntegerValue,
'' as WeekDayName --i need the t-sql to use for this column
答案 0 :(得分:2)
你应该使用DATENAME。 https://msdn.microsoft.com/en-us/library/ms174395.aspx
declare @currentDate as DATETIME;
set @currentDate = getdate();
SELECT DATEPART(dw, @currentDate) as WeekDayIntegerValue,
DATENAME(weekday, @currentDate) as WeekDayName
--i need the t-sql to use for this column
此外,你应该养成不使用日期功能快捷方式的习惯。