Monday, January 5, 2015

Sql server Get the Day of week

Suppose we have employee table and it has following rows and columns
Id
Name
Description
JoiningDate
1
Test1
Executive
10/5/2013 0:00
2
Test2
S.Executive
10/5/2012 0:00
3
Test3
Team Lead
10/5/2012 0:00
4
Test4
Jr Engineer
10/11/2014 0:00

select  case   DATEPART(DW,getdate())+@@DATEFIRST %WHEN 1 THEN 'SUNDAY'
    WHEN 2 THEN 'MONDAY'
    WHEN 3 THEN 'TUESDAY'
    WHEN 4 THEN 'WENSDAY'
    WHEN 5 THEN 'THURSDAY'
    WHEN 6 THEN 'FRIDAY'
    WHEN 7 THEN 'SATURDAY'
END

No comments:

Post a Comment

http://blogsiteslist.com