- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove seconds from MySQL Datetime?
To remove seconds from MySQL datetime, use UPDATE and SET as in the following syntax −
update yourTableName set yourDateColumnName=yourDateColumnName -second(yourDateColumnName);
Let us first create a table −
mysql> create table DemoTable -> ( -> Shippingdatetime datetime -> ); Query OK, 0 rows affected (0.76 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-01-21 12:05:20'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values('2019-03-01 10:23:35'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('2019-06-09 11:00:56'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+---------------------+ | Shippingdatetime | +---------------------+ | 2019-01-21 12:05:20 | | 2019-03-01 10:23:35 | | 2019-06-09 11:00:56 | +---------------------+ 3 rows in set (0.00 sec)
Here is the query to remove seconds from MySQL datetime −
mysql> update DemoTable set Shippingdatetime=Shippingdatetime-second(Shippingdatetime); Query OK, 3 rows affected (0.15 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check all records from the table once again −
mysql> select *from DemoTable;
Output
+---------------------+ | Shippingdatetime | +---------------------+ | 2019-01-21 12:05:00 | | 2019-03-01 10:23:00 | | 2019-06-09 11:00:00 | +---------------------+ 3 rows in set (0.00 sec)
- Related Articles
- Remove seconds from time field in MySQL?
- MySQL DateTime Now()+5 days/hours/minutes/seconds?
- How to get the total number of seconds from a MySQL DATETIME instance?
- MySQL strip time component from datetime?
- Remove Seconds/ Milliseconds from Date and convert to ISO String?
- What is the equivalent of MySQL TIME_TO_SEC() method in PHP to convert datetime to seconds?
- MySQL Query to convert from datetime to date?
- Create DATETIME from DATE and TIME in MySQL?
- Get only the date from datetime in MySQL?
- Compare DATE string with string from MySQL DATETIME field?
- How to select only MySQL date from datetime column?
- MySQL query to get only the minutes from datetime?
- Convert from varchar to datetime and compare in MySQL?
- Insert datetime into another datetime field in MySQL?
- How to part DATE and TIME from DATETIME in MySQL?

Advertisements