Find the number between two dates using ruby

HI,
I want to find the days between to dates. I have written the code by using ruby in logstash but i didnt get the value. Can anyone help me to resolve it.

field1:August 8th 2016, 03:52:35.000
field2:August 6th 2016, 03:52:35.000
ruby {
init => "require 'time'"
code => "event['rdr_dateDiff'] = event['field1'].to_i - event['field2'].to_i;"

}

How are you populating field1 and field2? With a date filter?

I didnt populate the date filter i'm just passing the 2 field into ruby code

Yes, but where are the values coming from? What is the data type of the contents of the fields? Your example, "August 8th 2016, 03:52:35.000", looks like something that Kibana has formatted for you. Output from a stdout { codec => rubydebug } output would be helpful.

This is the format of date will get in codec ""2016-08-11T13:38:24.065Z"

Okay. I suggest you use a date filter to parse those strings into the fields. Then you can perform date arithmetic in your ruby filter.

Can you give me the example for date filter

Check the documentation for examples. The ISO8601 date pattern should work for you.