MINUTE

Updated at:

The MINUTE function extracts the minute value (0 to 59) from the specified date value.

Syntax

INT MINUTE(DATETIME|TIMESTAMP|TIMESTAMP_NTZ|STRING|INTERVAL <date>)

-- Standard example.
-- Returns 46.
SELECT MINUTE('2025-03-05 10:46:00');

Parameters

date: required. A value of the DATETIME, TIMESTAMP, TIMESTAMP_NTZ, STRING, or INTERVAL type.

  • If date is of the STRING type, the date format must contain hh:mi:ss.

  • If date is of the INTERVAL type, only INTERVAL_DAY_TIME is supported. INTERVAL_YEAR_MONTH is not supported. For more information, see INTERVAL data type.

Return value

The function returns an INT value based on the following rules:

  • If date is not of the DATETIME, TIMESTAMP, TIMESTAMP_NTZ, STRING, or INTERVAL type, the function returns NULL or an error.

  • If date is NULL, the function returns NULL.

Examples

  • Example 1: Extract the minute value from a standard time.

    -- Returns 45.
    SELECT MINUTE(DATETIME '2025-03-05 12:45:10');
  • Example 2: Process a string input.

    -- Returns 15.
    SELECT MINUTE('2025-03-05 08:15:30');
  • Example 3: Process a boundary value and NULL.

    -- Returns NULL.
    SELECT MINUTE(NULL);
    
    -- Test the maximum minute value.
    -- Returns 59.
    SELECT MINUTE('2025-03-05 10:59:59');
  • Example 4: Extract the minute value from an INTERVAL_DAY_TIME value.

    -- Enable the MaxCompute V2.0 data type edition.
    SET odps.sql.type.system.odps2 = true;
    -- Returns 30.
    SELECT MINUTE(INTERVAL '2 10:30:45' DAY TO SECOND);

Related functions

MINUTE is a time function. For more information about functions for date calculations and conversions, see Date functions.