

- 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 will addition, subtraction, multiplication, and division operator work with date represented as MySQL string?
Such kind of calculations can cause unpredictable result because when the date is represented as MySQL string then MySQL tries to perform numeric operations on a string by taking only the first that appears. Following examples will clarify it −
mysql> select '2017-10-17' + 20; +-------------------+ | '2017-10-17' + 20 | +-------------------+ | 2037 | +-------------------+ 1 row in set, 1 warning (0.00 sec) mysql> select '2017-10-25' - 17; +-------------------+ | '2017-10-25' - 17 | +-------------------+ | 2000 | +-------------------+ 1 row in set, 1 warning (0.00 sec) mysql> select '2017-10-17' * 2; +-------------------+ | '2017-10-17' * 20 | +-------------------+ | 4034 | +-------------------+ 1 row in set, 1 warning (0.00 sec) mysql> select '2017-05-25'/5; +----------------+ | '2017-05-25'/5 | +----------------+ | 403.4 | +----------------+ 1 row in set, 1 warning (0.00 sec)
- Related Questions & Answers
- How will addition, subtraction, multiplication and division operator work with date values stored in MySQL table?
- How MySQL performs date arithmetic with addition and subtraction operators?
- How does comparison operator work with date values in MySQL?
- Signals and Systems: Addition and Subtraction of Signals
- Given an example of C pointer addition and subtraction
- How to get string as date in MySQL with dates as dot format specifier?
- Addition and Subtraction of Matrix using pthreads in C/C++
- Select timestamp as date string in MySQL?
- Explain the performance of Addition and Subtraction with signed magnitude data in computer architecture?
- Division Operator in C#
- Alternate addition multiplication in an array - JavaScript
- Performing the subtraction operation without the subtraction operator in JavaScript
- C++ program to find addition and subtraction using function call by address
- Evaluate a boolean expression represented as string in C++
- Divide large number represented as string in C++ Program
Advertisements