Reputation: 6733
I need to get day name from the given datetime using the SQL Server 2008 R2.
Example:
Given date:
'2014-11-14 00:00:00'
'2014-11-15 00:00:00'
Expected result:
Date Day Name of Date
----------------------------------
2014-11-14 Friday
2014-11-15 Saturday
Upvotes: 8
Views: 32716
Reputation: 868
You can use DATENAME
function
DECLARE @currentDay DATETIME = GETDATE(); -- 3 Apr 2019
SELECT DATENAME(dw,@currentDay);
-- Output:- Wednesday
Upvotes: 0
Reputation: 3216
select DATENAME(weekday,getdate())
SELECT CONVERT(VARCHAR(10), '2014-11-14 00:00:00', 105) AS DATE,
Datename(weekday, '2014-11-14 00:00:00') AS DayNameofDate
Upvotes: 15
Reputation: 2607
The function you need is DATENAME. http://msdn.microsoft.com/en-us/library/ms174395.aspx
Upvotes: 2