• Elapsed Between Timestamps

    Author
    Topic
    #353708

    Hello,

    I have a table with a field for date-and-time stamp. I created a query to show a subset of the table, sorted by the date-and-time stamp. Is it possible to add an expression to the query definition that will calculate the elapsed time from the previous date-and-time stamp?

    Thanks!

    Viewing 0 reply threads
    Author
    Replies
    • #518012

      Look at the DateDiff Function in the Help index, which returns the number of time intervals between two specified dates. Use Now() as the third argument to calculate the number of time intervals from the system date/time.

      • #518013

        Thanks, however the issue is still: I can refer to the date from the record in question easily enough for one of the inputs to DateDiff, but how do I refer to the date from the PREVIOUS record in the query result for the other input? I am comfortable with calculating elapsed times, I just don’t know how to reference the proper inputs.

        • #518378

          Sorry, I did not understand that one of the date/time stamps you needed to reference was in a previous record. The only way I know how to reference a previous record is by using VB. You would create a recordset, find the record, hold the date/time value, then move to the previous record to obtain the previous record’s date/time stamp. That would give you the references for the DateDiff calculation. If you like, I can post an example of VB code that moves between records to gather values or someone else may know a non-VB method to accomplish this.

          • #518464

            Thanks, that will not be necessary. The purpose for my question is more generic than Access, but since I am familiar with Access, I figured it would be a good test-bed.

            Thanks anyway!

    Viewing 0 reply threads
    Reply To: Elapsed Between Timestamps

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: