# Trying to calculate differences between 2 timestamps

**URL:** https://discuss.elastic.co/t/trying-to-calculate-differences-between-2-timestamps/242443
**Category:** Logstash
**Created:** [July 24, 2020, 4:31am UTC](https://discuss.elastic.co/t/trying-to-calculate-differences-between-2-timestamps/242443 "2020-07-24T04:31:34Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)
#### Post date: [July 24, 2020, 5:02am UTC](https://discuss.elastic.co/t/trying-to-calculate-differences-between-2-timestamps/242443/2 "2020-07-24T05:02:09Z")

</div>

I think it's always nice to ask an actual question in a post. Anyway, you can do that easily with a Ruby filter:

```auto
ruby {
  code => 'event.set("lag", event.get("@timestamp")-event.get("event_timestamp"))' 
}

```

---

_[View the full topic](https://discuss.elastic.co/t/trying-to-calculate-differences-between-2-timestamps/242443)._
