当前位置:网站首页>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 .
边栏推荐
猜你喜欢

Product axure9 (English version), prototype design background dynamic secondary menu display content

U-Net: Convolutional Networks for Biomedical Image Segmentation

【PyQt5系列】修改计数器实现控制

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

在线JSON转CSharp(C#)Class工具

Intelligence Education - how to merge codes when code conflicts occur in multi person collaborative development?

基于51单片机的温度检测监测报警系统设计

Simpledateformat thread safety issues

跳跃表原理

Cirium has gradually become the standard for airlines' carbon dioxide emission reporting
随机推荐
Use of Lombok
300. longest increasing subsequence
作为思摩尔应对气候变化紧急事件的一项举措,FEELM加入碳披露项目
都是硬盘分区 C盘和D盘到底有什么区别?
Yan's DP analysis
3dmax插件开发环境配置及FileExport和Utilities模板测试
【PyQt5系列】修改计数器实现控制
Spock sub piling
MySQL on duplicate key and PgSQL on conflict (primary key) handle primary key conflicts
Spock-sub打桩
MySQL(五) — 锁及事务
NFS 特别注意权限的问题
Yolov5 detecting small targets (with source code)
MySQL (II) - MySQL data type
如何优雅的快速下载谷歌云盘的大文件 (二)
SSM integration
数据库原理实验测试题,关于图书分类表
Spock约束-调用频率/目标/方法参数
Ldconfig command
303. region and retrieval - array immutable