计算时间查询 [英] Calculating Time Query

查看:81
本文介绍了计算时间查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在尝试计算时间时遇到了问题。没关系,如果价值不超过24小时,否则我会列出日期和时间。例如,我有一个循环查看表并累计花费的时间。

Hi,

I''m having an issue trying to calculate time. Its okay if the value does not exceed 24 hours otherwise I get a date and hours listed. For example, I have a loop which looks through a table and adds up the time spent.

展开 | 选择 | Wrap | 行号

推荐答案





我在尝试计算时间时遇到问题。没关系,如果价值不超过24小时,否则我会列出日期和时间。例如,我有一个循环,通过一个表来查看并累计花费的时间。


Dim TempCount As Date

Dim DEVCount As Date





TempCount = rst!wtime

DEVCount = DEVCount + TempCount

rst。 MoveNext

i = i +" 1"


循环直到rst!Anorder = 2


我有两个其他循环在AnOrder 2和3处循环并计算它们的总数。它们似乎没什么问题,因为他们的总数是9h:25m和17h:35m。但是订单1的DEVCount值是:2/1/1900 22:24:00。我想因为它超过了24小时的加入天数?有没有办法得到像37h这样的数字:44m或57h:24m ??


我知道将循环设置DEVCount作为日期和时间并从那里计算但是我认为这应该是一项轻松的任务似乎很长时间。


请帮助!!
Hi,

I''m having an issue trying to calculate time. Its okay if the value does not exceed 24 hours otherwise I get a date and hours listed. For example, I have a loop which looks through a table and adds up the time spent.

Dim TempCount As Date
Dim DEVCount As Date

Do

TempCount = rst!wtime
DEVCount = DEVCount + TempCount
rst.MoveNext
i = i + "1"

Loop Until rst!Anorder = 2

I have two other loops looping at AnOrder 2 and 3 and calculating their totals. They seems to be okay as their total are 9h:25m and 17h:35m. But DEVCount value for anOrder 1 is: 2/1/1900 22:24:00. I guess because its exceeding a 24hour period its adding days? Is there any way of getting a figure like 37h:44m or 57h:24m??

I know a way round it would be to set DEVCount as a date and time and calculate from there but it seems very long winded for what I think should be an easy task.

Please help!!



如果将时间值转换为分钟,则变得很简单。例如,1997分钟将是:

If you convert the Time Values to minutes, it then becomes a simple matter. For instance, 1997 minutes would be:

展开 | 选择 | Wrap | 行号


我无法使用,数据来自一个类似于下面但更多数据的查询!


用户anOrder时间

A 1 00:15(15分钟)

B 1 15:45(15小时45分钟)

C 1 13:30(13小时30分钟)

D 2 05:00(5小时)

E 2 00:30(30分钟)

F. 3 03:00(3小时)


这些是我想让Visual Basic计算的数字。


anOrder 1 = 29:30(29小时30分钟)

anOrder 2 = 05:30(5小时30分钟)

anOrder 3 = 03:00(3小时)



anOrder 2和anOrder 3很好(目前),因为他们不超过24小时,但是订单3并且我得到了约会。围绕着这个吗?
I can''t get that to work, the data is coming from a query which looks similar to below but more data!

User anOrder Time
A 1 00:15 (15 Minutes)
B 1 15:45 (15 Hours 45 Minutes)
C 1 13:30 (13 Hours 30 Minutes)
D 2 05:00 (5 Hours)
E 2 00:30 (30 Minutes)
F 3 03:00 (3 Hours)

These are the figures I''m trying to get Visual Basic to calculate.

anOrder 1 = 29:30 (29 hours 30 Minutes)
anOrder 2 = 05:30 (5 Hours 30 Minutes)
anOrder 3 = 03:00 (3 Hours)


anOrder 2 and anOrder 3 are fine (at the moment) because they don''t exceed 24 hours but anOrder 3 does and I get a date. Is there anyway around this?


这里只是我的个人意见,我相信ADezii会提出一个更加漂亮的解决方案:-)


您需要停止将这些视为日期!您已在Date数据类型中声明了变量,这使得Access可以理解地认为它们是日期值。你真正拥有的是一个包含时间数据的字符串,而不是一个保存时间数据的日期。


您会发现使用一些字符串操作函数将字符串拆分更简单然后将它连接起来。


问候,

Scott
Just my personal opinion here, and I''m sure ADezii will come up with a much more spiffy solution :-)

You need to stop treating these as Dates! You have declared your variables in the Date data type, which makes Access, understandably, think they are date values. What you really have, is a String that holds Time data, not a Date that holds Time data.

You will find it much simpler to use some string manipulation functions to split the string down, then concatenate it back.

Regards,
Scott


这篇关于计算时间查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆