Sql server -> Get current month name with number of days - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

Sql server -> Get current month name with number of days

In this article I am going to explain how to get the current month name with number of days in Sql server.


Implementation:

To get the name of the month with number of days run the below given query in Sql server:

declare @currentdate datetime
set @currentdate = getdate()
SELECT datename(month, @currentdate) as MonthName,
DATEPART(day, DATEADD(s,-1,DATEADD(month, DATEDIFF(month,0,@currentdate)+1,0))) as NumberOfDays

OR


declare @currentdate datetime
set @currentdate = getdate()
SELECT datename(month, @currentdate) as MonthName,

 DAY(DATEADD(day,-1,DATEADD(month, DATEDIFF(month, 0, @currentdate) + 1, 0))) as NumberOfDaysInMonth

Sql server -> Get current month name with number of days

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon