Calculate time difference between two different time values excluding weekends

Currently have a logstash conf file that is gathering events with two time fields, createdDate and closedDate. Have a ruby code that calculates the time difference which is working as intended but looking for a way to exclude weekends. Haven’t been able to see anything to accomplish this inside of the elastic stack.

Has anyone ever run into this or have any ideas on how to calculate inside elastic?

You will need more ruby code to resolve that. There are examples of excluding weekends from date ranges here and here. Google will be happy to find more for you.

That said, is that actually the problem you need to solve? Public holidays, religious holidays and cultural norms mean the answer to a question like "How many days was the office open between these two dates?" can have multiple answers even in a single city, never mind multiple countries.

Awesome, thank you! I’ll take a look at those. At the moment only looking to exclude weekends. Need to calculate the time difference (currently calculated in seconds, will convert to hours) but not take into account weekends.

Currently have a basic ruby code that looks like this:

ruby { code => "event['elapsed'] = (event['closedDate']-event['createdDate'])" }

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