【发布时间】:2024-01-16 07:25:01
【问题描述】:
大家好,我正在研究如何计算员工下班时的工资。这是我目前使用的代码:
Dim theStartTime As Date
Dim theEndTime As Date
Dim totalTime As String
theStartTime = "16:11:06"
theEndTime = "18:22:01"
totalTime = Format(CDbl((theEndTime - theStartTime) * 24), "#0.0")
所以工作时间是:2h 11m
现在,使用上面的计算代码,我得到 2.2。我需要添加什么才能让它计算 2:11 而不是 2:20 的正确时间?
大卫
【问题讨论】:
-
2 小时 11 分钟非常接近 2.2 小时。 (关闭一分钟)。
-
如果你做了#0.00,你可能会看到它类似于 2.18
-
啊,是的,放置#.## 效果更好。但是当它应该给2h 11m时它仍然给我2h 18m?所以它给了他们额外的 7 分钟不工作的时间。