Returns a character string that represents the specified datepart of the specified date. The datepart weekday played an interesting role. By using DATENAME() function you will get all textual week days name like Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday and Friday as well as day number also.
DATENAME() Function Example:
SELECT DATENAME(weekday, GETDATE())-- RETURN SATURDAY, SUNDAY, MONDAY ... SELECT DATEPART(weekday, GETDATE())-- RETURN 1, 2, 3.........
Another nice example is to get the textual Month Name from a given date. For different type of Month Name formatting visit my another post.
SELECT DATENAME(month,GETDATE()) [MONTH NAME] SELECT DATEPART(month,GETDATE()) [MONTH NO]
Use DAY(), MONTH(), YEAR():
SQL server standard Functions. DAY() built in SQL function return the day part from a given date. MONTH() built in SQL function return no of month from a given date & YEAR() built in SQL function used to get only the year.
SELECT DAY(GETDATE()) [Day], MONTH(GETDATE()) [Month], YEAR(GETDATE()) [Year]