# Automations to delete rows based on time

**URL:** <https://connect.superhuman.com/t/automations-to-delete-rows-based-on-time/28793>\
**Category:** Ask the Community\
**Created:** [February 9, 2022, 6:27pm UTC](https://connect.superhuman.com/t/automations-to-delete-rows-based-on-time/28793 "2022-02-09T18:27:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sabriel\_Parker](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/sabriel_parker/32/25135_2.png) [@Sabriel\_Parker](https://connect.superhuman.com/u/Sabriel_Parker)\
**Post date:** [February 9, 2022, 6:27pm UTC](https://connect.superhuman.com/t/automations-to-delete-rows-based-on-time/28793/1 "2022-02-09T18:27:31Z")

</div>

Hello! I want to optimize my doc and create an automation that deletes rows that are older than 9 months. I’m sure there’s a formula for this but could someone point me in the right direction?

---

<div class="post-metadata">

**Author:** ![Scott\_Collier-Weir](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/scott_collier-weir/32/29677_2.png) [@Scott\_Collier-Weir](https://connect.superhuman.com/u/Scott_Collier-Weir)\
**Post date:** [February 9, 2022, 7:40pm UTC](https://connect.superhuman.com/t/automations-to-delete-rows-based-on-time/28793/2 "2022-02-09T19:40:25Z")

</div>

Oh for SURE! Great idea - Doc optimization is always key:

In that realm you have a couple of options depending on the kind of data you are dealing with:  
**1. Archive that data to preserve it while still speeding up your doc**

> **Options and Resources**
>
> 1. @Connor_McCormick1 's archive method  
> [How to handle large docs (Archive Docs)](https://connect.superhuman.com/t/how-to-handle-large-docs-archive-docs/25887)
> 2. My archive method  
> [How to handle large docs (Archive Docs) - #13 by Scott\_Collier-Weir](https://connect.superhuman.com/t/how-to-handle-large-docs-archive-docs/25887/13)
> 
> Both methods will allow you to archive your data but preserve it within your doc allowing you to still query that data and run reports on it.

**2. Run an automation to delete your rows**  
While there are a lot of ways to do this, I would run an automation similar to the following:

- **When** : time-based automation that runs every day in the middle of the night
- **Then** : deleteRows -

```auto
targetTable.filter(date<=(today()-days(60))

```

That should essentially locate any rows where a date is at least 60 days old and erase it \_Dates are a little silly though sometimes and I haven’t tested the exact formula, but should work.

Reach out if you need any more help!

---

<div class="post-metadata">

**Author:** ![Sabriel\_Parker](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/sabriel_parker/32/25135_2.png) [@Sabriel\_Parker](https://connect.superhuman.com/u/Sabriel_Parker)\
**Post date:** [February 9, 2022, 9:01pm UTC](https://connect.superhuman.com/t/automations-to-delete-rows-based-on-time/28793/3 "2022-02-09T21:01:55Z")

</div>

Great thank you! This _should_ work though I certainly should have optimized before now as my doc is crashing constantly 😅

I will probably do both of these things: archive some and delete some.

Thanks again!

---

<div class="post-metadata">

**Author:** ![Christiaan\_Huizer](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/christiaan_huizer/32/28269_2.png) [@Christiaan\_Huizer](https://connect.superhuman.com/u/Christiaan_Huizer)\
**Post date:** [February 10, 2022, 8:16am UTC](https://connect.superhuman.com/t/automations-to-delete-rows-based-on-time/28793/4 "2022-02-10T08:16:12Z")

</div>

In case you are still looking for / working on solution the one below I tested and works. I created a table name Year. This table has a column with all the dates of the year 2021.

the automation runs every day  
in my test case 11h AM  
the delete action has a filter, the checked check box., [see also this blog](https://medium.com/@huizer/how-to-coda-a-check-box-13438ddc31b0)

the checkbox contains this function:  
`thisRow.date < Date(Today().Year(),Today().Month() - 9,Today().Day())`

 ![image](https://global.discourse-cdn.com/coda1/original/3X/3/2/3287e74afa9bbeda634ed1e7d6d5e3c03c11c807.png)

I am afraid that for many of us, the time based automations remain confusing due to the way they are set-up.

Enjoy, Christiaan

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/system/32/24484_2.png) [@system](https://connect.superhuman.com/u/system)\
**Post date:** [March 2, 2022, 12:53pm UTC](https://connect.superhuman.com/t/automations-to-delete-rows-based-on-time/28793/5 "2022-03-02T12:53:34Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
