惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
L
LangChain Blog
量子位
GbyAI
GbyAI
B
Blog RSS Feed
月光博客
月光博客
人人都是产品经理
人人都是产品经理
腾讯CDC
Recent Announcements
Recent Announcements
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
The Cloudflare Blog
D
Docker
Cyberwarzone
Cyberwarzone
U
Unit 42
NISL@THU
NISL@THU
C
Check Point Blog
B
Blog
大猫的无限游戏
大猫的无限游戏
Cisco Talos Blog
Cisco Talos Blog
Recorded Future
Recorded Future
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
P
Proofpoint News Feed
F
Fortinet All Blogs
V
V2EX
T
Threat Research - Cisco Blogs
T
Threatpost
S
SegmentFault 最新的问题
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
TaoSecurity Blog
TaoSecurity Blog
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
P
Privacy International News Feed
L
Lohrmann on Cybersecurity
AWS News Blog
AWS News Blog
G
Google Developers Blog
美团技术团队

博客园 - 代码猫

Spring boot 打成jar包,并运行jar包。 mybatis中大于等于小于等于的写法 Spring boot 自定义注解,Java通过反射获取注解,及注解的说明,附源码下载! Spring boot 自定义注解+@Aspect实现切面输出日志,附源码下载! HTML5 Canvas基础教程 SpringBoot+Jpa动态切换多数据源配置及实现 MySQL使用DATE_FORMAT()函数格式化日期 Java List转String数组与String数组转List MySQL使用IF函数来动态执行where条件 JPA忽略实体类某属性,不持久化某字段的解决方法 git 常用命令 Windows系统CMD窗口下,MySQL建库、还原数据库命令操作示例 Java JPA 报java.lang.IllegalArgumentException: Validation failed for query for method public abstract ...异常的一种原因和解决办法 MySQL 5.7 执行SQL报错:1055 - Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 的解决办法 Java8使用实现Runnable接口方式创建新线程的方法 windows查看端口被占用情况 Windows环境下设置Tomcat8以服务的形式运行,不再打开Tomcat窗口 MySql添加字段命令 Java中String、LocalDateTime、LocalDate、Date互转
MySQL中两个DateTime字段相减,得到秒,分,天数
代码猫 · 2020-11-30 · via 博客园 - 代码猫

MySQL中两个DateTime字段相减

假定表名为tblName,两个DateTime字段名分别为beginDateTime,endDateTime,以下是相关两个mysql日期字段相减的SQL语句,这种方式两字段跨天,月,年都无问题。

得到两个日期字段之间的秒数

selec t (UNIX_TIMESTAMP(endDateTime) - UNIX_TIMESTAMP(beginDateTime)) dif_second from tblName

得到两个日期字段之间的分数

selec t (UNIX_TIMESTAMP(endDateTime) - UNIX_TIMESTAMP(beginDateTime))/60 dif_minute from tblName

得到两个日期字段之间的天数

selec t (UNIX_TIMESTAMP(endDateTime) - UNIX_TIMESTAMP(beginDateTime))/(60*60*24) dif_minute from tblName

出处:https://blog.csdn.net/cqrf2006/article/details/42080559