Open In App

QUARTER () and SEC_TO_TIME () in MariaDB

Improve
Improve
Like Article
Like
Save
Share
Report

1. QUARTER Function :

In MariaDB, The QUARTER Function returns the quarter portion of a date value. In this function, the first parameter will be the date/DateTime. This 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, for the month of Apr-Jun would return 2, for the month of Jul-Sep would return 3 and for the month of Oct-Dec would return 4.

Syntax :

QUARTER( date_value )

Function Range Values : 

1 year = 12/3 = 4 Quarter 
Jan to Mar
Apr to Jun
Jul to Sep
Oct to Nov 

Parameter :

Parameter Description
Date_value A date or DateTime value from which to extract the quarter.

Return :

It will return the quarter portion of a date value.

Example-1 :

SELECT QUARTER('2020-02-17');

Output :

1

Example-2 :

SELECT QUARTER('2020-05-17 15:21:05');

Output:

2

Example-3 :

The Curdate() function will return the current quarter of the system date 

SELECT QUARTER(CURDATE());

Output :

4

2. SEC_TO_TIME Function :

In MariaDB, The SEC_TO_TIME Function is used to converts numeric seconds into a time value. In this function, the first parameter will be a second. This function return time values range from ‘-838:59:59’ to ‘838:59:59’. This function will format the result as “HH:MM: SS”.It works opposite to the  TIME_TO_SEC function.

Syntax : 

SEC_TO_TIME( seconds )

Function return values : 

Range : '-838:59:59' to '838:59:59'

Parameters :

Parameters Description
Seconds A numeric value representing the number of seconds. This value can be positive or negative.

Return :

Returns the time value.

Example-1 :

SELECT SEC_TO_TIME(5);

Output :

'00:00:05'

Example-2 :

SELECT SEC_TO_TIME(18700);

Output :

'05:11:40'

Example-3 :

SELECT SEC_TO_TIME(-999);

Output : 

'-00:16:39'

Last Updated : 31 Aug, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads