

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Can we add minutes to VARCHAR datetime records while applying INSERT statement in MySQL?
Yes, we can add minutes while inserting values in a table.Let us first create a table. Here, we have a column with VARCHAR records where in
mysql> create table DemoTable2026 -> ( -> ArrivalTime varchar(20) -> ); Query OK, 0 rows affected (0.40 sec)
Insert some records in the table using insert command. We are first converting the VARCHAR date and then adding minutes −
mysql> insert into DemoTable2026 values(date_add(str_to_date('2017-12-01 11:34:45','%Y-%m-%d %H:%i:%s'), INTERVAL 10 MINUTE)); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable2026 values(date_add(str_to_date('2015-01-31 10:00:00','%Y-%m-%d %H:%i:%s'), INTERVAL 5 MINUTE)); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable2026 values(date_add(str_to_date('2017-12-01 11:34:45','%Y-%m-%d %H:%i:%s'), INTERVAL 20 MINUTE)); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable2026;
This will produce the following output −
+---------------------+ | ArrivalTime | +---------------------+ | 2017-12-01 11:44:45 | | 2015-01-31 10:05:00 | | 2017-12-01 11:54:45 | +---------------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- How to add 30 minutes to datetime in MySQL?
- How can we specify default values in MySQL INSERT statement?
- Add10 minutes to MySQL datetime format?
- How can we use a MySQL subquery with INSERT statement?
- Can we insert records in a MySQL table without auto_increment values?
- How to add time in minutes in datetime string PHP?
- Can we use ADD and CHANGE with ALTER Statement in MySQL?
- Is there a need to insert auto_increment column values in MySQL while using INSERT statement?
- Insert datetime into another datetime field in MySQL?
- Can we use INTERVAL keyword while inserting date records in a MySQL table?
- How to add a where clause in a MySQL Insert statement?
- Convert from varchar to datetime and compare in MySQL?
- MySQL Datetime to add days?
- How to easily insert datetime in MySQL?
- Can we compare numbers in a MySQL varchar field?
Advertisements