SQL Keywords

SQL MINUTE

What is the SQL MINUTE keyword?

Returns or designates the minute component in date-time extraction, comparison, or interval arithmetic.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL MINUTE: PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, Snowflake, BigQuery, Redshift

SQL MINUTE Full Explanation

MINUTE is a temporal keyword that refers to the minute field of a time, timestamp, or interval value. It appears in three common contexts:1. Extraction – Used with EXTRACT (Standard SQL, PostgreSQL, BigQuery), DATEPART (SQL Server), or the MySQL/SQLite MINUTE() function to pull the minute (0-59) from a date-time expression.2. Interval specification – Combined with the INTERVAL literal to build relative time values such as INTERVAL '15' MINUTE or INTERVAL '2-30' HOUR TO MINUTE.3. Date arithmetic helpers – Accepted by functions like DATE_ADD, DATE_SUB, and TIMESTAMPADD as the unit that dictates how many minutes to add or subtract.The returned value is always an integer in the range 0 through 59. If the source expression is NULL, the result is NULL. When used in INTERVAL literals, MINUTE serves as the unit label and does not generate a result on its own.Caveats:- Some dialects (MySQL, SQLite) provide a dedicated MINUTE(expr) scalar function, whereas others require EXTRACT(MINUTE FROM expr).- SQL Server uses DATEPART(minute, expr) and DATEDIFF(minute, start, end).- INTERVAL syntax differs slightly between systems: PostgreSQL accepts INTERVAL '5 minutes', Oracle uses NUMTODSINTERVAL(5, 'MINUTE'), MySQL prefers INTERVAL 5 MINUTE in DATE_ADD.- Fractional minutes are not supported; you must convert to seconds for sub-minute precision.

SQL MINUTE Syntax

-- Standard SQL / PostgreSQL
SELECT EXTRACT(MINUTE FROM timestamp_expression);

-- MySQL / MariaDB
SELECT MINUTE(timestamp_expression);

-- SQL Server
SELECT DATEPART(minute, datetime_expression);

-- Interval literal (PostgreSQL, Standard SQL)
INTERVAL '10' MINUTE;

SQL MINUTE Parameters

Example Queries Using SQL MINUTE

-- 1. Extract the minute of a timestamp
SELECT EXTRACT(MINUTE FROM TIMESTAMP '2024-06-01 14:37:22') AS minute_part;

-- 2. Add 30 minutes to an order time (PostgreSQL)
SELECT order_id,
       order_time + INTERVAL '30' MINUTE AS ship_by
FROM   orders;

-- 3. MySQL: find rows created in the first 5 minutes of any hour
SELECT *
FROM   events
WHERE  MINUTE(created_at) < 5;

-- 4. SQL Server: difference in minutes between two dates
SELECT DATEDIFF(minute, start_time, end_time) AS minutes_elapsed
FROM   sessions;

Expected Output Using SQL MINUTE

  • Returns 37 for the given timestamp.
  • Produces a timestamp 30 minutes later than order_time.
  • Returns all event rows whose created_at minute value is 0-4.
  • Returns the integer count of minutes between start_time and end_time for each session.

Use Cases with SQL MINUTE

  • Grouping or filtering records by the minute portion of a timestamp
  • Calculating service-level agreements that are expressed in minutes
  • Building rolling or tumbling 15-minute windows in analytics queries
  • Adding or subtracting whole-minute offsets for scheduling, alerting, or TTL logic

Common Mistakes with SQL MINUTE

  • Using MINUTE as a standalone function in systems that only support EXTRACT or DATEPART.
  • Forgetting that minutes range from 0 to 59, which can cause off-by-one logic errors when computing hour boundaries.
  • Attempting to retrieve fractional minutes; use SECOND or MILLISECOND instead.
  • Mixing INTERVAL syntax across dialects (e.g., INTERVAL 5 MINUTE is valid in MySQL DATE_ADD but invalid in pure Standard SQL).

Related Topics

EXTRACT, DATEPART, HOUR, SECOND, INTERVAL, DATE_ADD

First Introduced In

SQL-92

Frequently Asked Questions

How do I extract minutes from a timestamp?

Use EXTRACT(MINUTE FROM timestamp) in Standard SQL or PostgreSQL. In MySQL, call MINUTE(timestamp). SQL Server users can call DATEPART(minute, timestamp).

How can I add minutes to a timestamp?

Most databases accept INTERVAL 'n' MINUTE added to a timestamp (PostgreSQL, Oracle). MySQL offers DATE_ADD(timestamp, INTERVAL n MINUTE), and SQL Server provides DATEADD(minute, n, timestamp).

What value range does MINUTE return?

The function always returns integers from 0 through 59. Null input returns Null.

Does MINUTE support fractional minutes?

No. For sub-minute precision, extract SECOND or MILLISECOND instead.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!