Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
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());