
- 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 values stored in MySQL table?
When we try to do such kind of operations with date values stored in the table then MySQL is assuming the date values as the number and perform the arithmetic.
Suppose we have a table named ‘example’ having a date value in ‘orderdate’ column then following arithmetic operation will clarify the above −
mysql> select * from example; +------------+ | orderdate | +------------+ | 2017-05-25 | +------------+ 1 row in set (0.00 sec) mysql> select orderdate+10 from example; +--------------+ | orderdate+10 | +--------------+ | 20170535 | +--------------+ 1 row in set (0.00 sec) mysql> select orderdate*10 from example; +--------------+ | orderdate*10 | +--------------+ | 201705250 | +--------------+ 1 row in set (0.00 sec) mysql> select orderdate-10 from example; +--------------+ | orderdate-10 | +--------------+ | 20170515 | +--------------+ 1 row in set (0.00 sec) mysql> select orderdate/10 from example; +--------------+ | orderdate/10 | +--------------+ | 2017052.5 | +--------------+ 1 row in set (0.00 sec)
- Related Articles
- How will addition, subtraction, multiplication, and division operator work with date represented as MySQL string?
- How MySQL performs date arithmetic with addition and subtraction operators?
- How does comparison operator work with date values in MySQL?
- Divide two integers without using multiplication, division and mod operator
- 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
- 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 MySQL stored GENERATED COLUMNS can work with built-in functions?
- How MySQL stored GENERATED COLUMNS can work with mathematical expressions?
- Explain addition and subtraction of algebraic equations.
- Signals and Systems: Addition and Subtraction of Signals
- How to change the date in a table with date records with MySQL?
- MySQL Stored Procedure calling with INT and VARCHAR values
- How to insert DATE in MySQL table with TRIGGERS?

Advertisements