How can I find the start-date and name (1, 2, 3, etc.) of a quarter from a given date?
int GetQuarterName(DateTime myDate)
{
return (int)Math.Ceiling(myDate.Month / 3.0);
}
DateTime GetQuarterStartingDate(DateTime myDate)
{
return new DateTime(myDate.Year,(3*GetQuarterName(myDate))-2,1);
}
GetQuarterName gets the "next" integer value of the current month number / 3.
GetQuarterStartingDate uses the output from GetQuarterName to work out the month value, the year part of the original date, and 1 to represent the first day of the month to return.
(Apologies for making no sense, I have flu. :( )