In
this article I am going to explain how to get the number of days in current
month in Sql server.
In
the previous article I have explained how to create autocomplete textbox usingangularjs in asp.net mvc application, how to fill dropdownlist using AngularJsin MVC and how to populate dropdownlist based on another dropdownlist usingAngularJs in MVC.
Implementation:
To
get the number of days in current in month run the below given query in Sql
server:
declare @currentdate datetime
set @currentdate =
getdate()
SELECT DATEPART(day, DATEADD(s,-1,DATEADD(month, DATEDIFF(month,0,@currentdate)+1,0))) as
NumberOfDaysInMonth
OR
declare @currentdate datetime
set @currentdate =
getdate()
SELECT DAY(DATEADD(day,-1,DATEADD(month, DATEDIFF(month, 0, @currentdate) + 1, 0))) as
NumberOfDaysInMonth
Result :
No comments:
Post a Comment