当前位置:网站首页>MONTHS_BETWEEN函数使用
MONTHS_BETWEEN函数使用
2022-06-27 19:39:00 【清平乐的技术专栏】
MONTHS_BETWEEN (date1, date2)
用于计算date1和date2之间有几个月。 date1-date2
-- 间隔月份:时间格式 结果带小数 16.516
SELECT MONTHS_BETWEEN('2022-05-28','2021-01-12')
-- 间隔月份:月份格式 结果整数:16
-- 方法一:拼接
SELECT MONTHS_BETWEEN(CONCAT(SUBSTR('2022-05-28',1,7),'-01'),
CONCAT(SUBSTR('2021-01-01',1,7),'-01'))
-- 方法二:截取
SELECT CONCAT(SPLIT(MONTHS_BETWEEN('2022-05-28','2021-01-12') ,"\\.")[0])
-- 间隔月份:四舍五入 17
SELECT ROUND(MONTHS_BETWEEN('2022-05-28','2021-01-12') ,0)
-- 间隔月份,向前取整 16
SELECT FLOOR(MONTHS_BETWEEN('2022-05-28','2021-01-12') )
-- 间隔月份,向后取整 17
SELECT CEIL(MONTHS_BETWEEN('2022-05-28','2021-01-12') )
-- 带汉字格式:1年零1.0个月
SELECT CONCAT(SPLIT(MONTHS_BETWEEN('2019-03-31','2018-02-28')/12,"\\.")[0],"年零",ROUND(MONTHS_BETWEEN('2019-03-31','2018-02-28')%12,1),"个月");
边栏推荐
- 美团20k软件测试工程师的经验分享
- Read write separation master-slave replication of MySQL
- YOLOv6:又快又准的目标检测框架开源啦
- VMware virtual machine PE startup
- Management system itclub (Part 2)
- [leetcode] dynamic programming solution split integer i[silver fox]
- How to delete "know this picture" on win11 desktop
- [LeetCode]515. 在每个树行中找最大值
- Gbase 8A OLAP analysis function cume_ Example of dist
- 豆沙绿保护你的双眼
猜你喜欢

Common problems encountered by burp Suite

Simulink method for exporting FMU model files

JVM memory structure when creating objects

YOLOv6:又快又准的目标检测框架开源啦
![[leetcode] dynamic programming solution partition array ii[arctic fox]](/img/a1/4644206db3e14c81f9f64e4da046bf.png)
[leetcode] dynamic programming solution partition array ii[arctic fox]
![\w和[A-Za-z0-9_],\d和[0-9]等价吗?](/img/96/2649c9cf95b06887b57fd8af2d41c2.png)
\w和[A-Za-z0-9_],\d和[0-9]等价吗?

Go from introduction to practice - error mechanism (note)

.NET学习笔记(五)----Lambda、Linq、匿名类(var)、扩展方法

I think I should start writing my own blog.

Read write separation master-slave replication of MySQL
随机推荐
Little known MySQL import data
深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
[LeetCode]动态规划解分割数组II[Arctic Fox]
Null pointer exception
[LeetCode]513. Find the value in the lower left corner of the tree
Secret script of test case design without leakage -- module test
Test birds with an annual salary of 50w+ are using this: JMeter script development -- extension function
Summary of Web testing and app testing by bat testing experts
oracle迁移mysql唯一索引大小写不区分别怕
Process control task
Figure countdownlatch and cyclicbarrier based on AQS queue
Management system itclub (Part 2)
GBase 8a数据库用户密码安全相关参数汇总
MYSQL和MongoDB的分析
分享|智慧环保-生态文明信息化解决方案(附PDF)
Go from introduction to actual combat - execute only once (note)
Test automatique de Test logiciel - test d'interface de l'introduction à la maîtrise, apprendre un peu chaque jour
Magic POI error in reading excel template file
大厂常用软件测试面试题三(附答案)
The create database of gbase 8A takes a long time to query and is suspected to be stuck