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

Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget