select*fromexample;+------------ +|orderdate |+------------+|2017-05-25|+------------+1rowinset(0.00sec)mysql>selectorderdate+10"> How do the addition, subtraction, multiplication and division operators work with date values ​​stored in MySQL tables?-Mysql Tutorial-php.cn

How do the addition, subtraction, multiplication and division operators work with date values stored in MySQL tables?

WBOY
Release: 2023-09-16 16:25:02
forward
998 people have browsed it

加法、减法、乘法和除法运算符如何处理 MySQL 表中存储的日期值?

When we try to do such operations on date values stored in the table, MySQL assumes the date values are numbers and performs arithmetic operations.

Suppose we have a table called "example" which has a date value in the "orderdate" column, then doing arithmetic 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)
Copy after login

The above is the detailed content of How do the addition, subtraction, multiplication and division operators work with date values stored in MySQL tables?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!