Calculate Elasped EndTime To Next Record StartTime field
:afrog: This is my first post and would like some help on making a table from an existing table that has PN, StartTime, EndTime fields. I am trying to find the calculated time from one record's end time to the next records StartTime. Any examples or help will be appreciated.
Joe
Re: Calculate Elasped EndTime To Next Record StartTime field
How do you store Start/End time?
Re: Calculate Elasped EndTime To Next Record StartTime field
First post!?? its says 2! lol j/k
http://www.vbforums.com/
what are you doing this in? Access?
Re: Calculate Elasped EndTime To Next Record StartTime field
I am working with MS-Access 2003 and the the data is in a table like :
PN is Text, StartDAte is DateTime, EndDAte is DateTime.
Re: Calculate Elasped EndTime To Next Record StartTime field
well it depends on what u want to have as elapsed time...
Hours? days? mins? all??
here is a simple sample...
VB Code:
SELECT Table5.PN, Table5.StartDate, Table5.EndDate, [EndDate]-[StartDate] AS Elapsed INTO ElapsedTime
FROM Table5;
Re: Calculate Elasped EndTime To Next Record StartTime field
Thanks for the sample, but it looks like this would look at the current row only. My real problem is that the Table is sorted by StartDate and I am trying to subtact the StartTime form the PREVIOUS records EndTime. Or the EndTime from the current record the the StartTime of the NEXT record.
Joe
Re: Calculate Elasped EndTime To Next Record StartTime field
Start and End times are in a MS-Access 2003 table. both are formated datetime
Re: Calculate Elasped EndTime To Next Record StartTime field
Yes I'm using MS-Access 2003 but I'm trying to use a Module in VBA for this action.
Re: Calculate Elasped EndTime To Next Record StartTime field
Static's code would create a table named ElapsedTime with all records with the elapsed time from start to end for that record.
If you wanted end of that record to start of the next record interval, create a recordset of * and walk it from the first record to the last record, saving the current record's end time in a variable, move to the next record, subtract the variable from the current record's start time (this is your "inter-record" time interval), record the current record's end time in the variable ... and repeat till the last record. What you do with the time interval at each step is up to you.
Re: Calculate Elasped EndTime To Next Record StartTime field
thanks for all your help. I bought a couple of new books to read up on VBA and try to incorporate your suggestions.