Mathemathical Operation on Date or Timestamp


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?


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.

1 Like

Thanks Magnus! :smiley: