using System; using System.Globalization; using System.Linq; using System.Collections.Generic; public class Test { public static DateTime GetEndOfMonth(DateTime start, bool workingDaysOnly) { int year = start.Year; int month = start.Month; int daysInMonth = CultureInfo.CurrentCulture.DateTimeFormat.Calendar.GetDaysInMonth(year, month); var dt = new DateTime(year, month, daysInMonth); if (workingDaysOnly) { switch (dt.DayOfWeek) { case DayOfWeek.Saturday: dt = dt.AddDays(-1); break; case DayOfWeek.Sunday: dt = dt.AddDays(-2); break; default: break; } } return dt; } public static void Main() { DateTime endOfMonth = GetEndOfMonth(DateTime.Today, true); Console.WriteLine(endOfMonth.ToString("d")); } }