Datetime 从SQL Server 2012中的工作日整数获取工作日名称
如何仅使用T-SQL而不使用CASE语句来获取知道周日整数值的周日名称 例如,如果week-day整数值为2,那么我需要获取'Monday'作为week-day名称Datetime 从SQL Server 2012中的工作日整数获取工作日名称,datetime,sql-server-2012,Datetime,Sql Server 2012,如何仅使用T-SQL而不使用CASE语句来获取知道周日整数值的周日名称 例如,如果week-day整数值为2,那么我需要获取'Monday'作为week-day名称 declare @currentDate as DATETIME; set @currentDate = getdate(); SELECT DATEPART(dw, @currentDate) as WeekDayIntegerValue, '' as WeekDayName --i need the t-sql t
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
您应该为此使用DATENAME 此外,您应该改掉不使用日期函数快捷方式的习惯
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