如何比较2个日期和时间以获得持续时间 [英] How to compare 2 dates and times to get duration

查看:86
本文介绍了如何比较2个日期和时间以获得持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个时间表,想要比较2个日期和时间以查找所花费的时间长度。


1.我在一个字段和开始时间中有一个开始日期在另一个。然后我想在另一个领域输入完成日期并在另一个领域完成时间。我基本上想比较字段以找到时间格式的持续时间。例如6小时30分钟= 06:30


谢谢

Christine。

I am creating a time sheet and want to compare 2 dates and times to find the length of time taken.

1. I have a start date in one field and start time in another. I then want to enter a finish date in another field and finish time in another. I basically want to compare the fields to find the duration in time format. eg 6 hrs and 30 mins = 06:30

Thanks
Christine.

推荐答案

@ jacc14


以下函数将返回您需要的值,如果字段为空则不返回任何值。将其粘贴到一个新模块并保存,然后您可以简单地在查询网格中调用该函数,例如这样简单地将您的字段名称传递给函数


TheField: HoursMins ([DateFrom],[TimeFrom],[DateTo],[TimeTo])

@jacc14
The following function will return the value you require and return nothing if a field is empty. Paste it into a new module and save then you can simply call the function in the query grid with a convention such as this Simply pass your field names into the function

TheField: HoursMins([DateFrom],[TimeFrom],[DateTo],[TimeTo])


展开 | 选择 | 换行 | 行号


如果没有控件为空,则将[StartDate]添加到[StartTime,将[EndDate]添加到[EndTime],然后从第二个结果中减去第一个结果。这可以被格式化为HH:nn。如果你选择。
If none of the controls is blank then add [StartDate] to [StartTime, add [EndDate] to [EndTime], then subtract the first result from the second. This can be formatted as "HH:nn" if you choose.


谢谢。这完美无缺。


然而它让我觉得我应该估计我的工作时间有多长。


我有一本杂志每小时可以打印2000份。因此,如果我的开始日期为28/05/10,开始时间为18:30,并且希望生成3000份,我希望在完成日期返回28/05/10,在完成时间返回20:00。 />

非常感谢

Christine
thank you . This has worked perfect.

However it has give me the idea that i should estimate prior how long i expect the job to take.

I have a magazine that prints 2000 copies an hour. Therefore if i have a start date of 28/05/10 and start time of 18:30 and wish to produce 3000 copies I want to return 28/05/10 in the finish date and 20:00 in the finish time.

Many thanks
Christine


这篇关于如何比较2个日期和时间以获得持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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