totn MariaDB Functions

MariaDB: QUARTER Function

This MariaDB tutorial explains how to use the MariaDB QUARTER function with syntax and examples.

Description

The MariaDB QUARTER function returns the quarter portion of a date value.

Syntax

The syntax for the QUARTER function in MariaDB is:

QUARTER( date_value )

Parameters or Arguments

date_value
A date or datetime value from which to extract the quarter.

Note

  • The QUARTER function returns the quarter (a number from 1 to 4) given a date value.
  • Dates that have a month of Jan-Mar would return 1.
  • Dates that have a month of Apr-Jun would return 2.
  • Dates that have a month of Jul-Sep would return 3.
  • Dates that have a month of Oct-Dec would return 4.
  • See also the EXTRACT, YEAR, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, and MICROSECOND functions.

Applies To

The QUARTER function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB QUARTER function examples and explore how to use the QUARTER function in MariaDB.

For example:

SELECT QUARTER('2014-02-17');
Result: 1

SELECT QUARTER('2014-02-17 15:21:05');
Result: 1

SELECT QUARTER('2013-05-19');
Result: 2

SELECT QUARTER('2013-07-21');
Result: 3

SELECT QUARTER('2013-11-09');
Result: 4

This last QUARTER example would display the quarter portion of the current system date (current system date is returned by the CURDATE function).

SELECT QUARTER(CURDATE());