![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Why doesn't MySQL support millisecond / microsecond precision?
The millisecond/ microsecond precision wasn’t supported in previous versions like 5.6.4. But now MySQL supports millisecond/ microsecond precision with timestamp, datetime, and time.
The official statement.
“MySQL now supports fractional seconds for TIME, DATETIME, and TIMESTAMP values, with up to microsecond precision”.
You can check the MySQL version on your system using the version() method.
mysql> SELECT version();
The following is the output.
+-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.01 sec)
Let us now see the syntax to check the date difference.
mysql> SELECT DATEDIFF(now(),now());
Output
+-----------------------+ | DATEDIFF(now(),now()) | +-----------------------+ | 0 | +-----------------------+ 1 row in set (0.03 sec)
Let us now see another example.
mysql> SELECT now(6);
The following is the output in microseconds.
+-----------------------+ | now(6) +-----------------------+ | 2018-11-11 17:13:25.485429 | +-----------------------+ 1 row in set (0.00 sec)
Advertisements