# Elapsed time since a record was updated

**URL:** https://community.glideapps.com/t/elapsed-time-since-a-record-was-updated/17976
**Category:** Ask for Help
**Created:** [November 5, 2020, 3:57am UTC](https://community.glideapps.com/t/elapsed-time-since-a-record-was-updated/17976 "2020-11-05T03:57:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![turbnz](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/turbnz/32/16107_2.png) [@turbnz](https://community.glideapps.com/u/turbnz)
#### Post date: [November 5, 2020, 3:57am UTC](https://community.glideapps.com/t/elapsed-time-since-a-record-was-updated/17976/1 "2020-11-05T03:57:26Z")

</div>

This is my app: [kitengacmh.glideapp.io](http://kitengacmh.glideapp.io)  
It’s used like a whiteboard to show where medical equipment is located within our department.  
I’d like to add a field that shows how long since a piece of equipment was moved to a new location. This is to make it easier to see if someone has forgotten to return their equipment or update the app.  
Can anyone think of a way of going this, without giving the user more to do?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [November 5, 2020, 4:04am UTC](https://community.glideapps.com/t/elapsed-time-since-a-record-was-updated/17976/2 "2020-11-05T04:04:16Z")

</div>

Yes, this is pretty straight forward.

- Add a timestamp column to your sheet that is populated with the special current timestamp value when an item is edited.
- Then create another column that calculates the elapsed time using a math function, something like the following:

 ![Screen Shot 2020-11-05 at 12.02.57 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/3/53ca9ad1f9dde0564f934cf64283af96c1cbca8a.png)

That should do it for you?

---

<div class="post-metadata">

### Author: ![turbnz](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/turbnz/32/16107_2.png) [@turbnz](https://community.glideapps.com/u/turbnz)
#### Post date: [November 22, 2020, 10:23pm UTC](https://community.glideapps.com/t/elapsed-time-since-a-record-was-updated/17976/3 "2020-11-22T22:23:49Z")

</div>

Darren thanks for reply. I couldn’t see how to do the “special current timestamp value when an item is edited”. A bit of googling found this script to add to my google sheet:  
function onEdit(e) {

var ss = SpreadsheetApp.getActiveSheet();  
var r = ss.getActiveCell();  
[//1.Change](https://1.Change) ‘Sheet1’ to be matching your sheet name  
if (r.getColumn() \< 9 && ss.getName()==‘Sheet1’) { // 2. If Edit is done in any column before Column (I) And sheet name is Sheet1 then:  
var celladdress =‘I’+ r.getRowIndex()  
ss.getRange(celladdress).setValue(new Date()).setNumberFormat(“MM/dd/yyyy hh:mm”);  
}  
};

Was this what you meant, or is there an easier way of doing it?

I’ve kind of got it working on a google sheet, except that when any record is updated the whole sheet recalculates and updates the NOW()-timestamp values too! I’m not that bothered, I can just give the user that time when an item was last moved.

Unfortunately however, none of this works on the app…  
The locations change on the app, and the glide data sheet, and the google sheet, but the google sheet won’t update the timestamp unless I update the location directly from there.  
Force-reloading the data from the glide website’s app page doesn’t work either.  
Any thoughts?

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [November 22, 2020, 10:54pm UTC](https://community.glideapps.com/t/elapsed-time-since-a-record-was-updated/17976/4 "2020-11-22T22:54:03Z")

</div>

You can use Special Values instead of trying to come up with a script.

> **[Glide Docs](https://www.glideapps.com/docs)**
>
> Welcome to Glide Docs, a steadily growing collection of articles and videos on how to use Glide. We can’t wait to see what you build!

As for the script, the function name doesn’t matter, but it will only work with triggers. In particular, the onChange trigger.

Steps 4 and 5 explain it more here.

> [@Tutorial: Arrayformula in Google Sheets, good practices & how to overcome Arrayformula restrictions with scripts](https://community.glideapps.com/t/tutorial-arrayformula-in-google-sheets-good-practices-how-to-overcome-arrayformula-restrictions-with-scripts/9727):
>
> Hi, Today I will show you the script that can make copying formulas down work, when it does not work with arrayformula. But first, let’s have some introductions about arrayformula, for those who has not used this before in Google Sheets, some equivalents in Glide and some good practices while using it. I hope it can help you in building your Glide apps as well as applying it in your normal day job. 
> 
> > **1/ Definition**
> >
> > Arrayformula is defined as “a range, mathematical expression using one cell range …
