Is there a C# function which will give me the last day of the most recently finished Quarter given a date?
For example,
var lastDayOfLastQuarter = So
Here's a simple function to give you the last day of the current quarter (assuming you're using a standard calendar).
DateTime LastDayOfQuarter(DateTime today)
{
int quarter = (today.Month-1) / 3;
int lastMonthInQuarter = (quarter +1) * 3;
int lastDayInMonth = DateTime.DaysInMonth(today.Year, lastMonthInQuarter);
return new DateTime(today.Year, lastMonthInQuarter, lastDayInMonth);
}
Hope that helps.