Getting the Last day of month in dot net using C#

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 1970
Here is the code,
public DateTime Get_Last_Day_Of_Month(DateTime dt)
{
return (Get_First_Day_Of_Month(dt)).AddMonths(1).AddDays(-1);
}

private DateTime Get_First_Day_Of_Month(DateTime dt)
{
return new DateTime(dt.Year, dt.Month, 1);
}
Response.Write(Get_Last_Day_Of_Month(DateTime.Now) + "<br/>");

Output:-
31/05/2015 12:00:00 AM

Comments or Responses

Login to post response