Assume Financial Quarters always start on the 1st of a month and they are always 3 calendar months long.
Different organisations start their Financial Year (FY) in different months - some may be 1st April , some may be 1st July or could be just 1st Jan (which will match normal Calendar Quarters).
Given a date and a month that the FY starts on how can you determine the start of the quarter that the date falls in.
E.g.
DateTime getStartOfFinancialQtr(DateTime date, int monthFinancialYearStartsOn)
15th Jan when FY starts Jan would = 1st Jan
getStartOfFinancialQtr(new DateTime(2013,1,15), 1) == new DateTime(2013,1,1)
15th August when FY starts April would be 1st July
getStartOfFinancialQtr(new DateTime(2013,8,15), 4) == new DateTime(2013,7,1)
BUT 15th Jan 2013 when FY starts February would be 1st November 2012
getStartOfFinancialQtr(new DateTime(2013,1,15), 2) == new DateTime(2012,11,1)
QuartersInYear
method to handle your definition of quarter. – jasonQuartersInYear
toreturn new List<DateTime>() { new DateTime(year, 2, 1), new DateTime(year, 5, 1), new DateTime(year, 8, 1), new DateTime(year, 11, 1), };
in the case that the Fiscal Year starts in February. ThenDateTime d = new DateTime(2013, 1, 15); Console.WriteLine(d.NearestQuarterEnd());
will print11/1/2012 12:00:00 AM
to the console. – jason