For quarter, try:
public DateTime GetQuarterEnd(DateTime dt)
{
int month = dt.Month;
month = ((month + 2) / 3) * 3;
return new DateTime(dt.Year, month, 1).AddMonths(1).AddDays(-1);
}
You add one month then subtract one day to get the last day of the quarter.