正确的访问时间总和 [英] correct sum of hours in access
问题描述
我在Access 2010数据库中有两列,其中包含一些计算字段:
I have two columns in an access 2010 database with some calculated field:
time_from time_until calculated_field(time_until-time_from)
10:45 15:00 4:15
13:15 16:00 2:45
11:10 16:00 4:50
08:00 15:00 7:00
08:00 23:00 15:00
到目前为止,这很好:计算字段已完成工作,告诉我总时数和分钟数... 现在,我需要一个计算字段的总和. 我放入了一个表达式生成器:= Sum([time_until]-[time_from]) 我想总和应该给我33:50 ...但是它给了我9:50.为什么会这样呢?有办法解决这个问题吗?
Now so far, it is good: calculated field did its job to tell me total hours and mins... now, I need a sum of a calculated field.... I put in an expression builder: =Sum([time_until]-[time_from]) I guess total sum should give me 33:50... but it gives me some 9:50. why is this happening? Is there a way to fix this?
更新: 当我这样说的时候:
update: when I put like this:
=Format(Sum([vrijeme_do]-[vrijeme_od])*24)
我得到一个小数点数字...我认为是正确的.... 例如25小时30分钟显示为25,5
I get a decimal point number... which I suppose is correct.... for example, 25hrs and 30mins is shown as 25,5
但是,如何将25,5格式化为25:30?
but, how do I format this 25,5 to look like 25:30?
推荐答案
类似于@HansUp的答案,无需像这样的VBA代码即可完成
Similar to the answer from @HansUp, it can be done without VBA code like so
Format(24 * Int(SUM(elapsed_time)) + Hour(SUM(elapsed_time)), "0") & ":" & Format(SUM(elapsed_time), "Nn")
这篇关于正确的访问时间总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!