Bug #84016 QUARTER() function limited in usefulness
Submitted: 30 Nov 2016 11:19
Reporter: Grant Wray Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: QUARTER()

[30 Nov 2016 11:19] Grant Wray
Description:
The function QUARTER() is limited in application. The only condition in which it operates is a year based on twelve months starting on 1st January, which is a limited subset of the various quarter-year models operating internationally.

How to repeat:
*Normal operation of the QUARTER() function reveals the issue. 
Examples of where the function could be used to simplify DATETIME calculations:
In what quarter of an academic year, which starts on the 1st September, does the date '1-June' fall? 
In what quarter of the UK (personal) tax year, which starts on the 6th April, does the date '1-December' fall?  In what quarter of the UK fiscal (corporation tax) year, which starts on the 1st April, does the date '1-October' fall? 

Suggested fix:
Introduce a second 'mode' or 'date' parameter so that the function operates with that defined offset, e.g. the first day of your year (1-APR) would give the most flexibility as a number of date calculations could be incorporated. Precedents for different modes of operation for QUARTER() are WEEK() and YEARWEEK(), where the various modes allow different definitions of the first week of the year.