当前位置:网站首页>How MySQL converts a date to a number
How MySQL converts a date to a number
2022-06-23 07:33:00 【Yisu cloud】
mysql How to convert a date to a number
This article introduces in detail “mysql How to convert a date to a number ”, Detailed content , The steps are clear , The details are handled properly , Hope this article “mysql How to convert a date to a number ” The article can help you solve your doubts , Let's follow Xiaobian's ideas and go deeper slowly , Let's learn new knowledge together .
2 A way to turn a date into a number :1、 Use TO_DAYS() function , You can convert the specified date value to an integer value representing the number of days , grammar “TO_DAYS( Specify date value )”.2、 Use TIME_TO_SEC() function , You can convert the specified date time value to an integer value representing the number of seconds , grammar “TIME_TO_SEC( Specify the date time value )”.
The operating environment of this tutorial :windows7 System 、mysql8 edition 、Dell G3 The computer .
mysql To convert a date into a number 2 Methods
1、 Use TO_DAYS() function
TO_DAYS() Function returns the date and year 0( date "0000-00-00") Days between .
namely : Give a date , Return a day ( Years for 0 Days since ).
Example :
select to_days('2022-01-08');
2、 Use TIME_TO_SEC() function
TIME_TO_SEC(time) Function returns the parameter time Time value converted to seconds , Change the formula to “ Hours ×3600+ minute ×60+ second ”.
SELECT TIME_TO_SEC('2022-01-08 15:15:15');
As can be seen from the execution results , According to the formula “15×3600+15×60+25” Result seconds 54915.
Read here , This article “mysql How to convert a date to a number ” The article has been introduced , If you want to master the knowledge points of this article, you need to practice and use it yourself to understand , If you want to know more about this article , Welcome to the Yisu cloud industry information channel .
边栏推荐
- 数据库原理实验测试题,关于图书分类表
- Spock约束-调用频率/目标/方法参数
- Mysql事务隔离级别
- JUnit unit test reports an error org junit. runners. model. InvalidTestClassError: Invalid test class ‘xxx‘ . No runnable meth
- leetcode210. Schedule II 207 Curriculum topology sorting DFS BFS
- Data types in tensorflow
- C WPF realizes dynamic loading of controls through binding
- Arthas thread command locates thread deadlock
- Arthas-thread命令定位线程死锁
- 基于51单片机的温度检测监测报警系统设计
猜你喜欢

The original cloud landed in deep water, and the cloud product family of Boyun container released four values

Operation on a bit of binary

Akamai-1.75 version-_ Abck parameter generation JS reverse analysis

MySQL (VIII) - explain

MySQL (11) - sorting out MySQL interview questions

Deep learning series 47: Super sub model real esrgan
![[game theory] basic knowledge](/img/eb/08b1ce5106e574dc42be58f72fbab9.jpg)
[game theory] basic knowledge

20BN-Jester完整数据集下载

Learning and using quartz scheduling framework

【PyQt5系列】修改计数器实现控制
随机推荐
控制台程序
MySQL (11) - sorting out MySQL interview questions
901. stock price span
MySQL (II) - MySQL data type
In depth learning series 46: face image super score gfp-gan
【AI实战】xgb.XGBRegressor之多回归MultiOutputRegressor调参2(GPU训练模型)
yolov5检测小目标(附源码)
309. the best time to buy and sell stocks includes the freezing period
Realization of rolling broadcast effect
Console Application
Data types in tensorflow
NTU-RGBD数据集下载及数据格式解析
MySQL summary
MySQL(四) — MySQL存储引擎
NPM download error NPM err code error
MySQL(二) — MySQL数据类型
[AI practice] xgb Xgbregression multioutputregressor parameter 2 (GPU training model)
RFID data security experiment: C # visual realization of parity check, CRC redundancy check and Hamming code check
Download the OSS file and modify the file name
Spock-sub打桩