Javascript 中 Excel 中的 CEILING fnc?

CEILING fnc in Excel in Javascript?

提问人:DJLConsulting 提问时间:7/4/2023 最后编辑:Mayukh BhattacharyaDJLConsulting 更新时间:7/4/2023 访问量:35

问:

Excel 中的 CEILING,用于从分钟(1 分钟 = 0.1、5 分钟 = 0.1、7 分钟 = 0.2 等)以 6 分钟为增量计算法定计费小时数,当将 CEIL 函数转换为 JS 时:当值为 例如时,以 ms 为单位不起作用。2 分钟 --> 0.2=CEILING(E2,6)/60var legal = Math.ceil(total_time, 6) / 6 where total_time is (date_end - date_start) / 60000 and date_end and date_start field values

输入的值不像在 Excel 中那样以 6 分钟的增量提供 CEILING,但30 min = 0.5

JavaScript Excel CEIL

评论

0赞 Keith 7/4/2023
对不起,你在这里问什么真的不清楚。您能否提供一些示例数据和预期输出,这可能有助于澄清您尝试do. ps的内容。 6 分钟是 6 * 1000 * 60 = 360000,而不是 60000
0赞 Keith 7/4/2023
也没有第二个参数,您需要乘以 6 才能与 Excell 相同。例如。Math.ceilMath.ceil(n * 6) / 6
0赞 DJLConsulting 7/4/2023
function ceiling(number, significance) { return Math.ceil(number / significance) * significance; } from stackoverflow.com/questions/49262842/...
1赞 DJLConsulting 7/4/2023
预期输出:1-6 = .1,7-12 = .2,13-18 = .3,19-24 = .4,25-30 = .5,31-36 = .6,37-42 = .7,43-48 = .8,49-54 = .9,55-60 = 1.0

答:

0赞 DJLConsulting 7/4/2023 #1

答案:返回 Math.ceil(n/6.0) / 10;

评论

0赞 Community 7/5/2023
正如目前所写的那样,你的答案尚不清楚。请编辑以添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。您可以在帮助中心找到有关如何写出好答案的更多信息。