Get the time between first and last record

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Get the time between first and last record

    Hi all,

    I have a result table. In the first record I have the start time and in each
    record obviously another time then at the last record I have the final time.
    All those records have a identical ID.

    Now I have to get the time spend between the first and the last record. This
    is were I am stuck. Any clues?

    Result Table:

    ID<tab>value<tab>time
    1<tab>A<tab>10:15
    1<tab>B<tab>10:20
    1<tab>C<tab>10:30

    So the time spend here would be for ID "1" 15 minutes.

    TIA.

    Nitai

    nitai_co Guest

  2. Similar Questions and Discussions

    1. Show record based on time
      I have a record in a DB with a start time and a stop time (their data types are set to datetime). i want to show the record if the current time...
    2. Time elapsed record
      Running FM 5.5 on PC. Is there a way to show elapsed times for each record in table view. I want to show how long a patient has been admitted to...
    3. Elapsed time record help.
      Running FM 5.5 on PC. Is there a way to show elapsed times for each record in table view. I want to show how long a patient has been admitted to...
    4. unzipping a record at a time
      I have successfully used zgrep in a script and loved every minute of it (still wet behind the ears). sub pulldata { my $data = `zgrep $key...
    5. Time Stamp on a record
      I have a subform within a form. When a user creates a new record in the subform, I would like to have the date/time automatically stamped on that...
  3. #2

    Default Re: Get the time between first and last record

    The ID is identical across all records? That's strange.

    Anyway, since the recordset is a collection, you can index it as an array. So
    your first record would be
    myQuery.time[1]
    and your last record would be
    myQuery.time[myQuery.RecordCount].

    jdeline Guest

  4. #3

    Default Re: Get the time between first and last record

    Assume that the entries in the 'time' column are in a datetime
    format. If they're not, you can easily convert them. Then you could
    try something like

    SELECT DATEDIFF(second, MIN(time), MAX(time)) as timeDiff
    WHERE ID = 1

    This will give the value you are looking for, in seconds.

    BKBK Guest

  5. #4

    Default Re: Get the time between first and last record

    BTW, "time" is a reserved word in some systems.
    jdeline Guest

  6. #5

    Default Re: Get the time between first and last record

    >... "time" is a reserved word in some systems.
    Yes, we must take JDeline's comment into account.

    Therefore, assume that the entries in the 'theTime' column are in a datetime
    format. If they're not, you can easily convert them. Then you could
    try something like

    SELECT DATEDIFF(second, MIN(theTime), MAX(theTime)) as timeDiff
    WHERE ID = 1

    This should give the value you are looking for, in seconds.


    BKBK Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139