Hint 2: http://delphi.about.com/li

There are only 4 possible answers for each function: 1, 2, 3 or 4.

Once you know the month, if the month of the date passed to the function is 1, 2 or 3, the quarter of the date is 1; 4, 5 or 6, the quarter is 2; 7, 8 or 9, the quarter is 3 and finally 10, 11 or 12 the quarter is 4.

If you take the current month, add 2 and then divide the result by 3, and discard the fraction, you get the number of the quarter. TRUNC((Month + 2) / 3) = CurrentQuarter

(1+2)/3 = 1

(2+2)/3 = 1.33333 (TRUNCating it discards the .33333)

(3+2)/3 = 1.66666 (TRUNCating it discards the .66666)

For the Previous quarter function, you have to subtract 1 from the resulting number and, if the result of this subtraction is 0, the previous quarter is 4.

For the Next quarter function, you have to add 1 to the resulting number and, if the result is 5, the next quarter is 1.

I hope that helps.