# Mathemathical Operation on Date or Timestamp

**URL:** https://discuss.elastic.co/t/mathemathical-operation-on-date-or-timestamp/51334
**Category:** Logstash
**Created:** [May 30, 2016, 2:58pm UTC](https://discuss.elastic.co/t/mathemathical-operation-on-date-or-timestamp/51334 "2016-05-30T14:58:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sombilat](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sombilat](https://discuss.elastic.co/u/sombilat)
#### Post date: [May 30, 2016, 2:58pm UTC](https://discuss.elastic.co/t/mathemathical-operation-on-date-or-timestamp/51334/1 "2016-05-30T14:58:09Z")

</div>

Hello,

I want to perform a Mathemathical operation on a date field.

I am getting a timestamp field like so:  
add\_field =\> ["received\_at", "%{@timestamp}"]

Now, I will create a seperate field with a Date before the received\_at field.  
add\_field =\> ["received\_from", "%{@timestamp} - 1"]

Is there a way to do like, a Minus 1 day from the field?

Or do you have a suggestion on how I manipulate this?

Thanks,

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [May 31, 2016, 7:47am UTC](https://discuss.elastic.co/t/mathemathical-operation-on-date-or-timestamp/51334/2 "2016-05-31T07:47:08Z")

</div>

You'll have to use a ruby filter for this. Internally the `@timestamp` value has a date/time data type that allows date/time arithmetic so it should be simple to subtract a day.

---

<div class="post-metadata">

### Author: ![sombilat](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sombilat](https://discuss.elastic.co/u/sombilat)
#### Post date: [May 31, 2016, 11:57am UTC](https://discuss.elastic.co/t/mathemathical-operation-on-date-or-timestamp/51334/3 "2016-05-31T11:57:28Z")

</div>

Thanks Magnus! 😃

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 4:55am UTC](https://discuss.elastic.co/t/mathemathical-operation-on-date-or-timestamp/51334/4 "2017-07-06T04:55:15Z")

</div>


