本文介绍了两个日期之间的MySQL周计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

这个问题困扰了我几天,就像计算两天之间的周数一样,例如:

I've been stuck with this issue for days, which is something like calculating the numbers of weeks that lies between two days, for example:

Select @Days = (datediff( week, @pdtFromDate, @pdtToDate) - 1) * 5

这将输出返回为257.

This returns the output as 257.

我需要将此脚本转换为MySQL.

I need to convert this script into MySQL.

推荐答案

DATEDIFF(@date1, @date2)/7

返回一个小数,我猜想您会用CEIL()ROUND()FLOOR()

That returns a fraction which I'm guessing you'll want to round in some way with CEIL(), ROUND() or FLOOR()

我的测试示例具有两个定义的日期:

My test example with two defined dates:

SELECT FLOOR(DATEDIFF(DATE(20090215), DATE(20090101))/7);

这篇关于两个日期之间的MySQL周计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 00:44