
- 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
How to add 30 minutes to datetime in MySQL?
To add minutes to a datetime you can use DATE_ADD() function from MySQL. In PHP, you can use strtotime().
To add 30 minutes in MySQL, the DATE_ADD() function is as follows −
select date_add(yourColumnName,interval 30 minute) from yourTableName;
To use the above syntax, let us create a table. The following is the query to create a table.
mysql> create table Add30MinutesDemo −> ( −> YourTime datetime −> ); Query OK, 0 rows affected (0.67 sec)
Insert records in the table with the help of following query −
mysql> insert into Add30MinutesDemo values(now()); Query OK, 1 row affected (0.21 sec)
Display records from table with the help of select statement. The query is as follows −
mysql> select *from Add30MinutesDemo;
The following is the output −
+---------------------+ | YourTime | +---------------------+ | 2018-12-07 18:03:51 | +---------------------+ 1 row in set (0.00 sec)
Here is the MySQL query to add 30 minutes to a column. The query is as follows −
mysql> select date_add(YourTime,interval 30 minute) from Add30MinutesDemo;
The following is the output −
+---------------------------------------+ | date_add(YourTime,interval 30 minute) | +---------------------------------------+ | 2018-12-07 18:33:51 | +---------------------------------------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- How to add 30 minutes to a JavaScript Date object?
- Add10 minutes to MySQL datetime format?
- How to add time in minutes in datetime string PHP?
- MySQL update datetime column values and add 10 years 3 months 22 days and 10 hours, 30 minutes to existing data?
- How to subtract 30 days from the current datetime in MySQL?
- Can we add minutes to VARCHAR datetime records while applying INSERT statement in MySQL?
- MySQL Datetime to add days?
- How to set cookies to expire in 30 minutes in JavaScript?
- MySQL query to get only the minutes from datetime?
- MySQL DateTime Now()+5 days/hours/minutes/seconds?
- Add 30 days to a value in a MySQL table?
- How to add a day to datetime field in MySQL query?
- How can I add one day to DATETIME field in MySQL query?
- How to add time in a MySQL column set with type DATETIME?
- How would I get a cron job to run every 30 minutes on Linux?
Advertisements