
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to add time in a MySQL column set with type DATETIME?
To add time to datetime, use ADDTIME() function in MySQL. Let us first create a table −
mysql> create table DemoTable1848 ( ShippingDate datetime ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1848 values('2019-10-11 12:30:45'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1848 values('2019-01-12 10:00:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1848 values('2019-12-03 17:30:00'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1848;
This will produce the following output −
+---------------------+ | ShippingDate | +---------------------+ | 2019-10-11 12:30:45 | | 2019-01-12 10:00:00 | | 2019-12-03 17:30:00 | +---------------------+ 3 rows in set (0.00 sec)
Here is the query to add time −
mysql> select addtime(ShippingDate,'4:40') from DemoTable1848;
This will produce the following output −
+------------------------------+ | addtime(ShippingDate,'4:40') | +------------------------------+ | 2019-10-11 17:10:45 | | 2019-01-12 14:40:00 | | 2019-12-03 22:10:00 | +------------------------------+ 3 rows in set (0.00 sec)
- Related Articles
- How to compare DateTime Column with only Date not time in MySQL?
- Add DATE and TIME fields to get DATETIME field in MySQL?
- Increment column value ‘ADD’ with MySQL SET clause
- Set new delay time in a MySQL column
- Set default value to a JSON type column in MySQL?
- How to add time in minutes in datetime string PHP?
- Add a single day to datetime field with MySQL INTERVAL
- How to set time data type to be only HH:MM in MySQL?
- How to add 30 minutes to datetime in MySQL?
- MySQL Datetime to add days?
- How to split the datetime column into date and time and compare individually in MySQL?
- How to add a day to datetime field in MySQL query?
- Add a new value to a column of data type enum in MySQL?
- How to add a “created at” column in a table to set the timestamp in MySQL?
- How do I add more members to my ENUM - type column in MySQL?

Advertisements