<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: No of Businessdays between two dates in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320108#M164585</link>
    <description>&lt;P&gt;Wow perfect answer. The small mistake what I did till now is &lt;BR /&gt;
|eval Date1=mvrange(start,end,86400) which was not giving the results.&lt;/P&gt;

&lt;P&gt;Thank you so much cmerriman. . Appreciate your quick response.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Dec 2017 06:18:14 GMT</pubDate>
    <dc:creator>snehalatha</dc:creator>
    <dc:date>2017-12-06T06:18:14Z</dc:date>
    <item>
      <title>No of Businessdays between two dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320105#M164582</link>
      <description>&lt;P&gt;Hi , The below give me the no of days between two dates but i want to calculate only no of business days between two dates.&lt;BR /&gt;
eval start=relative_time(now(),"@d") | &lt;BR /&gt;
eval start_string=strftime(start,"%Y-%m-%d %A")|&lt;BR /&gt;
eval end=strptime('time_submitted',"%Y-%m-%d %H:%M")| &lt;BR /&gt;
eval end_string=strftime(end,"%Y-%m-%d %A") |&lt;BR /&gt;
eval SLA_duration=round((start-end)/86400,0)|&lt;/P&gt;

&lt;P&gt;Please help me &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:04:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320105#M164582</guid>
      <dc:creator>snehalatha</dc:creator>
      <dc:date>2020-09-29T17:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: No of Businessdays between two dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320106#M164583</link>
      <description>&lt;P&gt;you'll want something like this at the end of your syntax (if I understand, it could probably replace &lt;CODE&gt;SLA_duration&lt;/CODE&gt; and &lt;CODE&gt;BusinessDays&lt;/CODE&gt; could be that field name, instead):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval Date1=mvrange(start,end,86400)
|eval BusinessDays=mvcount(mvfilter(NOT match(Date1,"(Sun|Sat).*")))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Dec 2017 13:56:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320106#M164583</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-12-05T13:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: No of Businessdays between two dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320107#M164584</link>
      <description>&lt;P&gt;I'd never used &lt;CODE&gt;mvrange&lt;/CODE&gt; before, so I was playing around with this answer. Fun new trick!&lt;/P&gt;

&lt;P&gt;A couple things I noticed - @snehalatha, if your value for &lt;CODE&gt;start&lt;/CODE&gt; is later/greater than your value for &lt;CODE&gt;end&lt;/CODE&gt; (seems likely, based on the way your calculation of &lt;CODE&gt;SLA_duration&lt;/CODE&gt; was subtracting &lt;CODE&gt;end&lt;/CODE&gt; from &lt;CODE&gt;start&lt;/CODE&gt; value) - then the first line will need to be:&lt;BR /&gt;
&lt;CODE&gt;|eval Date1=mvrange(end,start,86400)&lt;/CODE&gt;&lt;BR /&gt;
And at least with my testing, I needed to add a &lt;CODE&gt;strftime&lt;/CODE&gt; to the second line, so mine wound up like this:&lt;BR /&gt;
&lt;CODE&gt;|eval BusinessDays=mvcount(mvfilter(NOT match(strftime(Date1, "%A"),"(Sun|Sat).*")))&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 19:20:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320107#M164584</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-12-05T19:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: No of Businessdays between two dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320108#M164585</link>
      <description>&lt;P&gt;Wow perfect answer. The small mistake what I did till now is &lt;BR /&gt;
|eval Date1=mvrange(start,end,86400) which was not giving the results.&lt;/P&gt;

&lt;P&gt;Thank you so much cmerriman. . Appreciate your quick response.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 06:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320108#M164585</guid>
      <dc:creator>snehalatha</dc:creator>
      <dc:date>2017-12-06T06:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: No of Businessdays between two dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320109#M164586</link>
      <description>&lt;P&gt;,cmerriman, trying to use this solution for my dates that are already in epoch time (start and end dates). Unexpected results. Data is coming in from .csv files and date columns are a string (like “06/14/2019”) with no times. Which i am just converting to epoch time to do some math between dates. Struggling to avoid the weekend dates though. Data brought in through forwarder have all the additional date_ fields in Splunk, but not from the .csv file.&lt;/P&gt;

&lt;P&gt;WHAT I HAVE SO FAR (calculates the days just fine, but not sure how to eliminate the weekends, and only use business days (Mon-Fri) in the results):&lt;/P&gt;

&lt;P&gt;index=testdata&lt;BR /&gt;
| eval TriggerDateX = strptime(TriggerDate,"%m/%d/%y")&lt;BR /&gt;
| eval MailDateX = strptime(MailDate,"%m/%d/%y")&lt;BR /&gt;
| eval Diff = round((MailDateX-TriggerDateX)/86400,0)&lt;/P&gt;

&lt;P&gt;Appreciate the help. Joe&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 03:53:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/No-of-Businessdays-between-two-dates/m-p/320109#M164586</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-06-19T03:53:30Z</dc:date>
    </item>
  </channel>
</rss>

