Question Calculate time difference (DateDiff)...

c0dehunter

New member
Local time
Yesterday, 23:32
Joined
Apr 5, 2009
Messages
3
Hello,

I have a table, where it is recorded when workers sign in to work and sign out. These are two different columns (See attached picture - "Prihod" and "Odhod").
In third column ("Dobropis") I would like access to automatically calculate and save how long worker has been working, when a new record is added to the table.

Now, I know query for this would be
Code:
SELECT DATEDIFF("h",[Prihod],[Odhod])
 FROM Prihodi_Odhodi;

But I don't know where to put this?

untitled-3.jpg
 
Why? It can always be calculated in a query of the table when you need it. Why waste table space?
 
Because I am developing a Java application (for school graduation), where I need Access DB just for storing data.
It will be much easier to just pull data into application from one DB column, than calculating time difference in Java, which is complicated because of Date data type...
 
I'm not familiar with how Java works but I would think if it can get to a table then it can get to a query. Right?
 
As RuralGuy states if you perform the calculation in Access using a query then instead of using Java to point at the actual table instead get it to point at the query.

David
 
You've got a point there..
I've thought about querying from Java and getting back the result, but still, it would be handy for employer if he could just open DB on a server and see how long one has worked, without opening the Java client, not?
 
A query looks *exactly* like a table in Access except in can contain calculated fields. There should be no difference between looking at a table and looking at a query.
 

Users who are viewing this thread

Back
Top Bottom