How to Add Minutes to a Datetime in MySQL
Working with date and time values is a common requirement in MySQL applications. Whether you are building sales reports, scheduling systems, analytics dashboards, order-processing applications, or SaaS platforms, you will often need to add or subtract a specific number of minutes from a DATETIME value.
MySQL provides the DATE_ADD() function for this purpose. You can use it to add a specific number of minutes to a DATE, DATETIME, or compatible temporal value.
The basic syntax is:
SELECT DATE_ADD(datetime_column, INTERVAL number MINUTE);For example, to add 30 minutes to a sales_time column:
SELECT sales_time,
DATE_ADD(sales_time, INTERVAL 30 MINUTE) AS new_time
FROM sales;This returns the original datetime together with a new datetime that is exactly 30 minutes later.
Example: How to Add Minutes to Datetime in MySQL
Suppose we have a table named sales containing information about products sold at different grocery stores.
The table contains a sales_time column with both the date and time of each sale.
You can create the table with:
CREATE TABLE sales (
store_ID INT PRIMARY KEY,
item TEXT NOT NULL,
sales_time DATETIME NOT NULL
);Next, insert some sample data:
INSERT INTO sales VALUES
(1, 'Oranges', '2024-02-10 03:45:00'),
(2, 'Apples', '2020-11-25 15:25:01'),
(3, 'Bananas', '2009-06-30 09:01:39'),
(4, 'Melons', '2024-01-14 03:29:55'),
(5, 'Grapes', '2023-05-19 23:10:04');You can view the data using:
SELECT *
FROM sales;The result is:
+----------+---------+---------------------+
| store_ID | item | sales_time |
+----------+---------+---------------------+
| 1 | Oranges | 2024-02-10 03:45:00 |
| 2 | Apples | 2020-11-25 15:25:01 |
| 3 | Bananas | 2009-06-30 09:01:39 |
| 4 | Melons | 2024-01-14 03:29:55 |
| 5 | Grapes | 2023-05-19 23:10:04 |
+----------+---------+---------------------+Add 30 Minutes to a Datetime in MySQL
To add 30 minutes to every value in the sales_time column, use:
SELECT sales_time,
DATE_ADD(sales_time, INTERVAL 30 MINUTE) AS new_time
FROM sales;The result is:
+---------------------+---------------------+
| sales_time | new_time |
+---------------------+---------------------+
| 2024-02-10 03:45:00 | 2024-02-10 04:15:00 |
| 2020-11-25 15:25:01 | 2020-11-25 15:55:01 |
| 2009-06-30 09:01:39 | 2009-06-30 09:31:39 |
| 2024-01-14 03:29:55 | 2024-01-14 03:59:55 |
| 2023-05-19 23:10:04 | 2023-05-19 23:40:04 |
+---------------------+---------------------+The original sales_time values are not modified. The query simply calculates a new datetime value.
How DATE_ADD() Works
The general syntax of DATE_ADD() is:
DATE_ADD(date, INTERVAL value unit)In this example:
DATE_ADD(sales_time, INTERVAL 30 MINUTE)the components are:
sales_time— the original date and time.INTERVAL— tells MySQL that an interval should be added.30— the number of units to add.MINUTE— the unit being added.
Therefore:
2024-02-10 03:45:00
+ 30 minutes
= 2024-02-10 04:15:00Give the Calculated Column a Name Using AS
Without an alias, MySQL may display the entire expression as the column name.
Instead, you can use AS to provide a meaningful name:
SELECT
sales_time,
DATE_ADD(sales_time, INTERVAL 30 MINUTE) AS addthirty
FROM sales;The output becomes:
+---------------------+---------------------+
| sales_time | addthirty |
+---------------------+---------------------+
| 2024-02-10 03:45:00 | 2024-02-10 04:15:00 |
| 2020-11-25 15:25:01 | 2020-11-25 15:55:01 |
| 2009-06-30 09:01:39 | 2009-06-30 09:31:39 |
| 2024-01-14 03:29:55 | 2024-01-14 03:59:55 |
| 2023-05-19 23:10:04 | 2023-05-19 23:40:04 |
+---------------------+---------------------+A more descriptive alias such as sales_time_plus_30 may be even clearer:
SELECT
sales_time,
DATE_ADD(sales_time, INTERVAL 30 MINUTE) AS sales_time_plus_30
FROM sales;Add Different Numbers of Minutes
You are not limited to 30 minutes. The number after INTERVAL can be changed according to your requirements.
For example, add 5 minutes:
SELECT DATE_ADD(sales_time, INTERVAL 5 MINUTE)
FROM sales;Add 15 minutes:
SELECT DATE_ADD(sales_time, INTERVAL 15 MINUTE)
FROM sales;Add 60 minutes:
SELECT DATE_ADD(sales_time, INTERVAL 60 MINUTE)
FROM sales;Add 90 minutes:
SELECT DATE_ADD(sales_time, INTERVAL 90 MINUTE)
FROM sales;Adding 60 minutes effectively moves the datetime forward by one hour.
Adding 90 minutes moves it forward by one hour and 30 minutes.
Add Minutes That Cross Into the Next Hour
DATE_ADD() automatically handles changes to the hour.
For example:
SELECT DATE_ADD('2024-02-10 03:45:00', INTERVAL 30 MINUTE) AS new_time;returns:
2024-02-10 04:15:00The calculation crosses from 03:00 to 04:00 automatically.
You do not need to manually calculate the hour.
Add Minutes That Cross Into the Next Day
MySQL also automatically handles changes to the date.
For example:
SELECT DATE_ADD('2024-02-10 23:45:00', INTERVAL 30 MINUTE) AS new_time;returns:
2024-02-11 00:15:00The date changes from February 10 to February 11 because the additional 30 minutes crosses midnight.
This is one of the advantages of using MySQL date and time functions instead of manually manipulating strings.
Add Minutes That Cross Into the Next Month
The same behavior applies when the calculation crosses a month boundary.
For example:
SELECT DATE_ADD('2024-01-31 23:45:00', INTERVAL 30 MINUTE) AS new_time;returns:
2024-02-01 00:15:00MySQL automatically adjusts the date, month, and time.
Add Minutes That Cross Into the Next Year
You can even add minutes to a datetime near the end of a year:
SELECT DATE_ADD('2024-12-31 23:45:00', INTERVAL 30 MINUTE) AS new_time;The result is:
2025-01-01 00:15:00This makes DATE_ADD() useful for scheduling, event processing, and time-based analytics.
Add Minutes Using a Column
The number of minutes does not necessarily have to be hard-coded.
Suppose another column contains the number of minutes to add:
CREATE TABLE appointments (
appointment_id INT PRIMARY KEY,
appointment_time DATETIME NOT NULL,
duration_minutes INT NOT NULL
);You can calculate the end time dynamically:
SELECT
appointment_time,
duration_minutes,
DATE_ADD(
appointment_time,
INTERVAL duration_minutes MINUTE
) AS end_time
FROM appointments;This can be useful for appointment systems, employee scheduling, delivery applications, and reservation platforms.
Add Minutes to the Current Date and Time
If you want to add minutes to the current date and time, use NOW():
SELECT
NOW() AS current_time,
DATE_ADD(NOW(), INTERVAL 30 MINUTE) AS time_after_30_minutes;For example, if the current time is:
2026-08-17 20:00:00the calculated value would be:
2026-08-17 20:30:00The exact result depends on the current MySQL server/session time.
Add Minutes to a Specific Datetime
You can also provide a datetime directly:
SELECT DATE_ADD(
'2024-02-10 03:45:00',
INTERVAL 30 MINUTE
) AS new_time;Result:
+---------------------+
| new_time |
+---------------------+
| 2024-02-10 04:15:00 |
+---------------------+This is useful for testing date calculations before incorporating them into a larger query.
How to Subtract Minutes in MySQL
If you need to subtract minutes rather than add them, use DATE_SUB().
For example:
SELECT
sales_time,
DATE_SUB(sales_time, INTERVAL 30 MINUTE) AS previous_time
FROM sales;For a value such as:
2024-02-10 03:45:00the result is:
2024-02-10 03:15:00You can think of the two functions as:
DATE_ADD(date, INTERVAL 30 MINUTE)for adding time, and:
DATE_SUB(date, INTERVAL 30 MINUTE)for subtracting time.
Add Minutes Using INTERVAL Syntax
MySQL supports several time units with DATE_ADD().
For example:
SELECT DATE_ADD(sales_time, INTERVAL 30 MINUTE)
FROM sales;You can also work with:
SELECT DATE_ADD(sales_time, INTERVAL 2 HOUR)
FROM sales;or:
SELECT DATE_ADD(sales_time, INTERVAL 1 DAY)
FROM sales;Other commonly used units include:
SECONDMINUTEHOURDAYWEEKMONTHQUARTERYEAR
For minute calculations, the important syntax is:
INTERVAL number MINUTEDATE_ADD() vs Direct Arithmetic
You may sometimes see MySQL queries that use arithmetic instead of DATE_ADD().
For example:
SELECT sales_time + INTERVAL 30 MINUTE
FROM sales;This is also valid MySQL syntax and can be concise.
However, DATE_ADD() is often easier to read in tutorials, complex queries, and code that needs to clearly communicate the date operation.
For example:
SELECT
sales_time,
DATE_ADD(sales_time, INTERVAL 30 MINUTE) AS new_time
FROM sales;clearly communicates that 30 minutes are being added to the datetime.
Practical Use Cases for Adding Minutes
Adding minutes to datetime values has many real-world applications.
Appointment Scheduling
Suppose an appointment begins at 2:00 PM and lasts 45 minutes:
SELECT DATE_ADD(
'2024-06-15 14:00:00',
INTERVAL 45 MINUTE
) AS appointment_end;The result is:
2024-06-15 14:45:00Delivery Time Estimates
A delivery application might estimate that an order will arrive 30 minutes after it is placed:
SELECT
order_time,
DATE_ADD(order_time, INTERVAL 30 MINUTE) AS estimated_delivery
FROM orders;Customer Support SLAs
A support system could calculate an SLA deadline 60 minutes after a ticket is created:
SELECT
created_at,
DATE_ADD(created_at, INTERVAL 60 MINUTE) AS sla_deadline
FROM support_tickets;Data Analytics
Analytics systems can create future time windows for event analysis:
SELECT
event_time,
DATE_ADD(event_time, INTERVAL 15 MINUTE) AS window_end
FROM events;This can be useful when analyzing website activity, application logs, IoT events, and real-time data streams.
Financial Applications
Financial systems may need to calculate time-based processing windows, settlement deadlines, or market-event intervals.
For example:
SELECT
transaction_time,
DATE_ADD(transaction_time, INTERVAL 30 MINUTE) AS processing_deadline
FROM transactions;Filtering Records Within a Time Window
You can also combine DATE_ADD() with a WHERE clause.
Suppose you want records that occurred within 30 minutes after a specific event:
SELECT *
FROM sales
WHERE sales_time >= '2024-02-10 03:45:00'
AND sales_time < DATE_ADD('2024-02-10 03:45:00', INTERVAL 30 MINUTE);This creates a half-open time interval:
2024-02-10 03:45:00 <= sales_time < 2024-02-10 04:15:00This pattern is useful in event processing and analytics because it avoids ambiguity around the exact boundary.
Adding Minutes to a TIMESTAMP Column
DATE_ADD() can also be used with a TIMESTAMP column.
For example:
SELECT
created_at,
DATE_ADD(created_at, INTERVAL 30 MINUTE) AS adjusted_time
FROM events;The exact behavior of TIMESTAMP values can depend on MySQL’s time-zone handling, so applications that operate across multiple time zones should establish a consistent time-zone strategy.
For many business applications, storing timestamps consistently and converting them for display is safer than mixing time zones throughout database calculations.
Complete MySQL Example
The following script provides a complete example that you can copy and run:
CREATE TABLE sales (
store_ID INT PRIMARY KEY,
item TEXT NOT NULL,
sales_time DATETIME NOT NULL
);
INSERT INTO sales VALUES
(1, 'Oranges', '2024-02-10 03:45:00'),
(2, 'Apples', '2020-11-25 15:25:01'),
(3, 'Bananas', '2009-06-30 09:01:39'),
(4, 'Melons', '2024-01-14 03:29:55'),
(5, 'Grapes', '2023-05-19 23:10:04');
SELECT
sales_time,
DATE_ADD(sales_time, INTERVAL 30 MINUTE) AS add_thirty_minutes
FROM sales;The expected result is:
+---------------------+---------------------+
| sales_time | add_thirty_minutes |
+---------------------+---------------------+
| 2024-02-10 03:45:00 | 2024-02-10 04:15:00 |
| 2020-11-25 15:25:01 | 2020-11-25 15:55:01 |
| 2009-06-30 09:01:39 | 2009-06-30 09:31:39 |
| 2024-01-14 03:29:55 | 2024-01-14 03:59:55 |
| 2023-05-19 23:10:04 | 2023-05-19 23:40:04 |
+---------------------+---------------------+Frequently Asked Questions
How do I add 30 minutes to a datetime in MySQL?
Use the DATE_ADD() function:
SELECT DATE_ADD(sales_time, INTERVAL 30 MINUTE)
FROM sales;How do I add 10 minutes to a datetime in MySQL?
Use:
SELECT DATE_ADD(sales_time, INTERVAL 10 MINUTE)
FROM sales;How do I add 60 minutes to a datetime?
Use:
SELECT DATE_ADD(sales_time, INTERVAL 60 MINUTE)
FROM sales;Adding 60 minutes moves the datetime forward by one hour.
How do I subtract 30 minutes in MySQL?
Use DATE_SUB():
SELECT DATE_SUB(sales_time, INTERVAL 30 MINUTE)
FROM sales;Can I add minutes to the current time?
Yes. Use NOW():
SELECT DATE_ADD(NOW(), INTERVAL 30 MINUTE);Can the number of minutes come from another column?
Yes. For example:
SELECT
start_time,
duration_minutes,
DATE_ADD(
start_time,
INTERVAL duration_minutes MINUTE
) AS end_time
FROM appointments;This lets every row use a different duration.
Does DATE_ADD() handle crossing midnight?
Yes. MySQL automatically adjusts the date when adding minutes crosses midnight.
For example:
SELECT DATE_ADD(
'2024-02-10 23:45:00',
INTERVAL 30 MINUTE
);returns:
2024-02-11 00:15:00Conclusion
MySQL’s DATE_ADD() function provides a straightforward way to add minutes to a DATETIME or other supported temporal value.
The basic syntax is:
DATE_ADD(datetime_value, INTERVAL number MINUTE)For example, to add 30 minutes to every value in a sales_time column:
SELECT
sales_time,
DATE_ADD(sales_time, INTERVAL 30 MINUTE) AS new_time
FROM sales;If you need to subtract minutes, use:
DATE_SUB(sales_time, INTERVAL 30 MINUTE)Because MySQL automatically handles changes to hours, days, months, and years, DATE_ADD() is a practical solution for appointment scheduling, delivery estimates, SLA calculations, event processing, analytics, and other applications that require reliable datetime manipulation.