Datediff麻烦 [英] Datediff trouble

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

问题描述

哇,我今天悲惨地失败了。 : - (


我有一个包含三个列的表:fill_start,fill_end,fill_dur.Fill_dur应该计算fill_start和fill_end之间的分钟差异。我知道计算结果只是= DateDiff(" n",[Fill_Start],[Fill_End])但我不知道在哪里放这个让它工作。


一些背景可能会有所不同:Fill_Start和_End是日期/时间短时间格式(例如17:34).Fill_Dur是一个数字字段。


如果我将DateDiff函数放在未绑定的文本框中(称为txt_DateDiff),那么它很好地计算了这个值。我尝试在每个可以想到的事件中设置Me.Fill_Dur = Me.txt_DateDiff(afterupdate,getfocus,lostfocus等等)无济于事。我还把这个函数放在当前事件等的表格中。


我应该把这个野兽放在哪里?


感谢您的帮助

melissa

解决方案


哇我今天惨遭失败。 : - (


我有一个包含三个列的表:fill_start,fill_end,fill_dur.Fill_dur应该计算fill_start和fill_end之间的分钟差异。我知道计算结果只是= DateDiff(" n",[Fill_Start],[Fill_End])但我不知道在哪里放这个让它工作。


一些背景可能会有所不同:Fill_Start和_End是日期/时间短时间格式(例如17:34).Fill_Dur是一个数字字段。


如果我将DateDiff函数放在未绑定的文本框中(称为txt_DateDiff),那么它很好地计算了这个值。我尝试在每个可以想到的事件中设置Me.Fill_Dur = Me.txt_DateDiff(afterupdate,getfocus,lostfocus等等)无济于事。我还把这个函数放在当前事件等的表格中。


我应该把这个野兽放在哪里?


感谢您的帮助

melissa


嗯,根据经验,你不能存储由于维护所需的开销,计算出的值就像在表中一样。


你只能在需要时计算它。


什么'是头顶上的?真的那么多,它不值得做吗?是否涉及数学会减慢速度?


感谢您的帮助



什么头顶上的?真的那么多,它不值得做吗?是否涉及数学会减慢速度?


感谢您的帮助



嗯,你可以看到你需要每当更改任何相关字段时重新计算。它也浪费空间,因为如果你需要的话,所有的信息都可以用来计算价值。


但是如果你想要存储它还是有一个绑定的文本框到Fill_Dur。在影响计算的每个文本框的After Update事件中,重新计算Fill_Dur字段。没有必要第三个盒子。您还需要锁定Fill_Dur字段。


Wow I''m failing miserably today. :-(

I have a table with three colums: fill_start, fill_end, fill_dur. Fill_dur is supposed to calculate the difference in minutes between fill_start and fill_end. I know the calculation is simply =DateDiff("n", [Fill_Start], [Fill_End]) but I have no idea WHERE to put this to make it work.

Some background that might make a difference: Fill_Start and _End are date/time short time format (17:34 for example). Fill_Dur is a number field.

If I put the DateDiff function in an unbound textbox (called txt_DateDiff) then it calculates the value beautifully. I tried setting Me.Fill_Dur = Me.txt_DateDiff in every event conceivable (afterupdate, getfocus, lostfocus, etc etc) to no avail. I also put the function into the form on current event etc.

Where am I supposed to put this beast?

thanks for any help
melissa

解决方案

Wow I''m failing miserably today. :-(

I have a table with three colums: fill_start, fill_end, fill_dur. Fill_dur is supposed to calculate the difference in minutes between fill_start and fill_end. I know the calculation is simply =DateDiff("n", [Fill_Start], [Fill_End]) but I have no idea WHERE to put this to make it work.

Some background that might make a difference: Fill_Start and _End are date/time short time format (17:34 for example). Fill_Dur is a number field.

If I put the DateDiff function in an unbound textbox (called txt_DateDiff) then it calculates the value beautifully. I tried setting Me.Fill_Dur = Me.txt_DateDiff in every event conceivable (afterupdate, getfocus, lostfocus, etc etc) to no avail. I also put the function into the form on current event etc.

Where am I supposed to put this beast?

thanks for any help
melissa

Well, as a rule of thumb, you don''t store calculated values like that in a table because of the overhead required for upkeep.

You would only calculate it when you need it.


What''s the overhead? Is it really so much that it''s not worth doing? Is it the math involved that slows things up?

thanks for the help


What''s the overhead? Is it really so much that it''s not worth doing? Is it the math involved that slows things up?

thanks for the help

Well, as you can see you need to recalculate whenever any of the related fields are changed. It''s also a waste of space as all the information is already avaiable to calculate the value if you need it.

But if you want to store it anyways, have a bound textbox to Fill_Dur. And in the After Update events of each textbox that affects the calculation, recalculate the Fill_Dur field. There''s no need for a third box. You''ll also want to lock the Fill_Dur field.


这篇关于Datediff麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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