4
Reply

What is difference between Datepart() and Datename() in SqlServer?

    Both are predefined functions available in SqlServer 2005 on wards. They are generally use to fetch part of date. For instance "08/13/2015" we want to fetch year only.Datepart() returns value as Integer. But Datename() returns value as string characters. So you can't do any operation like add 1 year to result in case of Datename() but you can do with Datepart().More on this please visit: http://www.c-sharpcorner.com/Blogs/49779/difference-between-datename-and-datepart-in-sql-server.aspx

    Both are almost same but in case of return value datepart returns INTEGER where datename returns stringie. datepart(month,getdate()) = 1 datename(month,getdate()) = january

    detepart() gives the particular section(eg: year or month) in a date and datename function returns name of the particular datepart.. datepart(month,"12/05/1990")->gives 05; datename(month,"12/05/1990")->gives may;

    Both are almost same but in case of return value datepart returns INTEGER where datename returns string