Get last date and first date of the month, using C#

Posted In Asp.net - By admin On Wednesday, August 26th, 2009 With 0 Comments

In this code we can get current month last date and first date , using C#.Net

 

DateTime firstDay= new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

 int DaysinMonth = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)-1;

DateTime lastDay = firstDay.AddDays(DaysinMonth);

About -

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>