关于根据营业时间计算小时数的代码的问题 [英] Question on Code that calculates hours based on business hours
本文介绍了关于根据营业时间计算小时数的代码的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据库中有一些代码可以计算两个日期/时间字段之间的时间,还可以计算周末和假日。我没有创建这个代码,所以我有点不知道为什么它不能正常工作。
我有桌子,一个叫工作时间,它有两个字段,wStart和wEnd。在这些领域,我有08:30和18:30。另一个表有假期,两个字段,hName,它有假日的名字,hDate,它是假日的日期。
这是代码:
展开 | 选择 | Wrap | 行号
解决方案
我只有几分钟的时间来查看代码,但尝试使用以下代码替换Code#37。如果这样可行,我会解释原因:
展开 | 选择 | Wrap | 行号
计算似乎有效,但奇怪的是继续当我在查询中使用此代码时,结果会出现,但是当我单击计算所在的字段时,它会不断更改为上面记录中的内容。
这里我在查询中提到的内容:
cTotalHours:HCalc([oDateSentTc],[oFinalDateT],是)
oDateSentTC oFinalDateT cTotalHours
10/2/2009 3:22:04 PM 10/7/2009 1:37:00 PM 30.03
10/2/2009 3:22:13 PM 10/7/2009 1:37:00 PM 28.25
10/5/2009 11:45:00 AM 10/8/2009 11:47:00 AM 28.25
10/5/2009 9:17:12 AM 10/5/2009 3:53:37 PM 6.6
10/5/2009 11:45:00 AM 10/8/2009 11 :上午47:00 30.03
10/5/2009 9:17:12 AM 10/5/2009 3:53:37 PM 6.6
二几分钟后,我又做了一次:
oDateSentTC oFinalDateT cTotalHours
10/2/2009 3:22:04 PM 10/7/2009 1:37 :00 PM 28.25
10/2/2009 3:22:13 PM 10/7/2009 1:37:00 PM 28.25
10/5/2009 11:上午45:00 10/8/2009 11:47:00 AM 28.25
10/5/2 009 9:17:12 AM 10/5/2009 3:53:37 PM 6.6
10/5/2009 11:45:00 AM 10/8/2009 11:47:00 AM 30.03
10/5/2009 9:17:12 AM 10/5/2009 3:53:37 PM 6.6
10/5/2009 11:45:00 AM 10/8/2009 11:47:00 AM 30.03
看看第一次计算如何变化?如果我点击计算,有时我得到30.03,有时候得到28.85。它遍布整个地方。
任何想法?
再次感谢。
Kelly
您可以附加数据库或其中的一部分?
I have some code in my database that calculates time between two date/time fields and also calculates the weekends and holidays. I did not create this code, so I''m at a bit of a loss why it''s not working correctly.
I have to tables, one is called Working Hours, which has two fields, wStart and wEnd. In those fields, I have 08:30 and 18:30. The other table has the Holidays, two fields, hName, which has the name of the holiday, and hDate, which is the date of the holiday.
Here is the code:
Expand|Select|Wrap|Line Numbers解决方案I''ve only had a couple of minutes to look at the code, but try replacing Code Line #37 with the following. If this works, I''ll then explain why:
Expand|Select|Wrap|Line Numbers
The calculations seem to be working, but something strange is going on. When I use this code in a query, the results come up, but when I click on the field where the calculation resides, it keeps changing to what is in the record above.
Here''s what I put in the query:
cTotalHours: HCalc([oDateSentTc],[oFinalDateT],Yes)
oDateSentTC oFinalDateT cTotalHours
10/2/2009 3:22:04 PM 10/7/2009 1:37:00 PM 30.03
10/2/2009 3:22:13 PM 10/7/2009 1:37:00 PM 28.25
10/5/2009 11:45:00 AM 10/8/2009 11:47:00 AM 28.25
10/5/2009 9:17:12 AM 10/5/2009 3:53:37 PM 6.6
10/5/2009 11:45:00 AM 10/8/2009 11:47:00 AM 30.03
10/5/2009 9:17:12 AM 10/5/2009 3:53:37 PM 6.6
Two minutes later, I do it again:
oDateSentTC oFinalDateT cTotalHours
10/2/2009 3:22:04 PM 10/7/2009 1:37:00 PM 28.25
10/2/2009 3:22:13 PM 10/7/2009 1:37:00 PM 28.25
10/5/2009 11:45:00 AM 10/8/2009 11:47:00 AM 28.25
10/5/2009 9:17:12 AM 10/5/2009 3:53:37 PM 6.6
10/5/2009 11:45:00 AM 10/8/2009 11:47:00 AM 30.03
10/5/2009 9:17:12 AM 10/5/2009 3:53:37 PM 6.6
10/5/2009 11:45:00 AM 10/8/2009 11:47:00 AM 30.03
See how the first calculation changed? If I click on the calculation, sometimes I get 30.03 and sometimes 28.85. It does this all over the place.
Any ideas?
Thanks again.
Kelly
Can you Attach the Database, or a Segment of it?
这篇关于关于根据营业时间计算小时数的代码的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆