Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

QUARTER

Example

Retrieve the quarter of the year for a given date.

SELECT QUARTER(“2017-06-15”);

Definition and Usage

The QUARTER() function returns the quarter of the year (1 to 4) corresponding to a given date value.

  • January-March returns 1
  • April-June returns 2
  • July-Sep returns 3
  • Oct-Dec returns 4

Syntax

QUARTER(date)

Parameter Values

Parameter

Description

date

Mandatory: The date or datetime from which to extract the quarter.

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Retrieve the quarter of the year for a specified date.

SELECT QUARTER(“2017-01-01 09:34:21”);

Example

Retrieve the quarter of the year corresponding to the given date.

SELECT QUARTER(CURDATE());