Can I subtract time within the same column?

G

Greenfleas

I have a database with a column for time, and I would like to calculate the
difference between times sequentially. For example in Excel, I would
subtract (A2-A1). Is there a way to do this in Access 2003?
 
V

vbasean

I have a database with a column for time, and I would like to calculate the
difference between times sequentially.  For example in Excel, I would
subtract (A2-A1).  Is there a way to do this in Access 2003?

Create a Query

add the table with the time in it
add the two time fields to the query
in the third field (any blank field) add the formula

TimeDifference: [your first time field] - [your second time field]
 
D

Dale Fye

ah, grasshopper, you misunderstand.

the OP wants to determine the difference between values of the same field,
in consecutive records.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



vbasean said:
I have a database with a column for time, and I would like to calculate the
difference between times sequentially. For example in Excel, I would
subtract (A2-A1). Is there a way to do this in Access 2003?

Create a Query

add the table with the time in it
add the two time fields to the query
in the third field (any blank field) add the formula

TimeDifference: [your first time field] - [your second time field]
 
D

Dale Fye

you can, but fiirst you have to be able to define what consecutive records are.

Since data in a table basically has no (it's like a bunch of marbles tossed
in a bag), if you don't have a way of ordering the data, then this is not
feasible. So, if you have a date/time field that contains both date and
time, then you could do it, or if you have some sort of record # (I would not
include an autonumber field in this category) that is guaranteed to be
increasing in order, you could do it. With a date/time field, it might look
something like:

SELECT T1.[DateTimeField],
Datediff('n', T1.[DateTimeField], DMIN("DateTimeField",
"YourTable", "[DateTimeField] > #" & T1.[DateTimeField] & "#")) as ElapsedTime
FROM YourTable T1
GROUP BY T1.[DateTimeField]

HTH
Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top