473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Datediff trouble

AccessIdiot
493 256MB
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
Mar 27 '07 #1
10 1712
Rabbit
12,516 Expert Mod 8TB
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.
Mar 28 '07 #2
AccessIdiot
493 256MB
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
Mar 28 '07 #3
Rabbit
12,516 Expert Mod 8TB
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.
Mar 28 '07 #4
AccessIdiot
493 256MB
Thanks for that. I discussed with the guys who wanted it in the first place and told them it would be a drag on the db so they relented and said okay to having it calculate at report time.

Thanks for helping me!
Mar 28 '07 #5
Rabbit
12,516 Expert Mod 8TB
Not a problem.

If they want to see that number just have it in an unbound textbox with the control source set to the calculation.

And at report time it can recalculate it. So it is basically what they want without actually storing the value.
Mar 28 '07 #6
AccessIdiot
493 256MB
Spot on, as usual! :-)
Mar 28 '07 #7
Rabbit
12,516 Expert Mod 8TB
Spot on, as usual! :-)
Good Luck!
Mar 28 '07 #8
NeoPa
32,556 Expert Mod 16PB
Hey Rabbit - 4 digit posts - cool :)
Melissa, Rabbit's already told you exactly what I would have said. It's definitely the way to handle it. Storing calculated (or calculable) fields is just a way of asking the gods to give you a head-ache ;) Easier to go straight there with a mega drinking binge. Probably more fun too :D
Mar 29 '07 #9
AccessIdiot
493 256MB
Yeah I don't know what we were thinking. There are a bunch of other things we were planning on leaving out simply because they didn't need to be stored but could just be inserted at report time so I don't know why we didn't throw this one in that pile.

No binge drinking for me until my baby girl is done with HER drinking if you know what I mean! :-D
Mar 29 '07 #10
NeoPa
32,556 Expert Mod 16PB
I surely do :)
I can't say I've been there exactly (not in this lifetime at least) as I'm definitely of the wrong gender for that sort of thing, but I lived through it from the other side a couple of times all the same.
Mar 29 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: CJM | last post by:
I have an ASP page that lists files and folders in a directory. I'm using a cookie to record the last time this page was visited, and I intend to show links that are created/modified from that date...
8
by: inamori | last post by:
I face that problems 07/01/2003 06/30/2006 ---------> it should be 3 01/01/2003 02/28/2005 --------->could i get 2 years and 2 months 01/01/2003 03/01/2005 ...
4
by: John Smith | last post by:
Hi, I'm having trouble working out the best way of calculating the time difference between two times on the same day. The example I have found does return the hours (in this case 8) but forgets...
4
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS...
1
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
6
by: kevinjwilson | last post by:
I am trying to get the date difference between two dates but I don't want the function to include weekends in the calculation. Does anyone have an idea on how to make this work?
2
by: muddasirmunir | last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff i had try it withh many syntax but getting error...
16
by: double kanon | last post by:
hi i am having trouble with this paystub program i am working on. so the console is supposed to ask for the start time and end time then calculate the pay with the rate given. How can i enter the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.