我们可以通过提供单位值“季度”来实现这一目标EXTARCT()
。示例如下-
mysql> Select EXTRACT(Quarter from '2017-07-29'); +------------------------------------+ | EXTRACT(Quarter from '2017-07-29') | +------------------------------------+ | 3 | +------------------------------------+ 1 row in set (0.00 sec)
上面的查询将给出从特定给定日期开始的季度值。
mysql> Select EXTRACT(Quarter from now()); +-----------------------------+ | EXTRACT(Quarter from now()) | +-----------------------------+ | 4 | +-----------------------------+ 1 row in set (0.00 sec)
上面的查询将给出从当前日期开始的季度的值。