Results 1 to 10 of 10

Thread: Calculate Elasped EndTime To Next Record StartTime field

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    Post Calculate Elasped EndTime To Next Record StartTime field

    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
    Last edited by JoeAtBell; Aug 11th, 2006 at 08:08 AM. Reason: deleting question to remove space

  2. #2

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Calculate Elasped EndTime To Next Record StartTime field

    First post!?? its says 2! lol j/k


    what are you doing this in? Access?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    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.

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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:
    1. SELECT Table5.PN, Table5.StartDate, Table5.EndDate, [EndDate]-[StartDate] AS Elapsed INTO ElapsedTime
    2. FROM Table5;
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    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

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    Re: Calculate Elasped EndTime To Next Record StartTime field

    Start and End times are in a MS-Access 2003 table. both are formated datetime

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    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.

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  10. #10

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width