# Add time to existing total time column

(Dialect Junk) #1

We have a piece of equipment that we’re trying to track while it’s in operation. We have a “Start” and “Stop” action to capture respective timestamps, and a “Total Time” column to calculate total run time.

The equipment can run multiple times a day with variable amount of stops, so we want to be able to hit “Start/Stop” multiple time with the “Total Time” column updating with the actual time the equipment was running.

Is this possible without adding dozens of “Total Time” columns for each occurrence?..

(Levent Kulacoglu) #2

@Dialect_Junk
You can set a [START] column (Type: Time) and [CHANGE TIMESTAMP] column (Type: Change Timestamp). Bind this [CHANGE TIMESTAMP] column to watch any column data change you want. Than your you can calculate your [TOTAL TIME] column with an expression i.e.

`TIME([CHANGE TIMESTAMP]) - [START]`

(Dialect Junk) #3

Will this provide a running total to the [Total Time] column?

Say that today I have 2 sets of start/end times for my equipment:

I hit “Start” at 9am, “End” at 11am for 2 hours.
I hit “Start” at 2pm, “End” at 6pm for 4 hours.

Will my [Total Time] update to 6 hours?

(Levent Kulacoglu) #4

@Dialect_Junk
You can do it this way:
You have `[START]` and `[END]` columns. Create 2 actions which will record a datetime stamp to these columns with Data: change a value of a column & use `NOW()` as a value.
Create 2 Virtual Columns in your table:
(1) STEP_TOTAL with an expression of `TIME([END]) - TIME([START])`
(2) TOTAL with an expression of `[TOTAL] + [STEP_TOTAL]`

(Dialect Junk) #5

Levent, thanks for the suggestion. I gave that I try but the Virtual Column [TOTAL] is adding my [Total Time] column to the [STEP_TOTAL] column, essentially just doubling my [Total Time] column. I’m sure I’m missing something…

(Aleksi Alkio) #6

This was interesting request from Mr @LeventK so I made a small sample app how you can do that. It will calculate total as minutes. The app name is “IN and OUT” and you can find it from here… https://www.appsheet.com/portfolio/531778

1 Like
(Dialect Junk) #7

Thank you, both!