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
Try this:
The AddMonths(-(d.Month-1) % 3)) moves the datevalue to the equivilent day of the first month in the quarter, and then the AddDays (-day) moves back to the last day of the preceding month.
DateTime d = Datetime.Now;
DateTime lastDayOfLastQuarter = d.AddMonths(-((d.Month-1)%3)).AddDays(-d.Day);