
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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 Articles
- 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?
- Performing an operation, such as addition, subtraction, multiplication or division, on any two integers and the result will always be an integer. This property of integers is known as
- How does comparison operator work with date values in MySQL?
- Divide two integers without using multiplication, division and mod operator
- Explain addition and subtraction of fractions with example.
- Explain Closure property of addition and subtraction with example.
- Explain the addition and subtraction of integers with examples.
- How to get string as date in MySQL with dates as dot format specifier?
- Explain addition and subtraction of algebraic equations.
- Signals and Systems: Addition and Subtraction of Signals
- Select timestamp as date string in MySQL?
- Given an example of C pointer addition and subtraction
- Give properties of addition and subtraction for whole numbers.
- How We Will Know That In Word Problems We Have To Do Addition ,subtraction, Multiply Or Divide ?

Advertisements