<?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: How to calculate number of days between the beginning of the month to a date within the same month? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/233915#M69513</link>
    <description>&lt;P&gt;are the dates you are calculating between values in fields? Are they the range from the time picker?&lt;/P&gt;

&lt;P&gt;If they are values in fields, it'd be as simple as &lt;CODE&gt;|eval daysBetween=round((time2-time1)/86400,0)&lt;/CODE&gt; given that the time fields are in epoch, if not, you'll need to do some more evaling with either &lt;CODE&gt;strftime&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If the values are from the time picker, use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|gentimes start=-1 | addinfo | dedup info_min_time info_max_time 
          | eval daysBetween=round((info_max_time-info_min_time)/86400,2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 10 Jan 2017 14:48:02 GMT</pubDate>
    <dc:creator>cmerriman</dc:creator>
    <dc:date>2017-01-10T14:48:02Z</dc:date>
    <item>
      <title>How to calculate number of days between the beginning of the month to a date within the same month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/233914#M69512</link>
      <description>&lt;P&gt;Let's say the date is 20th of feb, 2017. I need to calculate the number of days starting from 1st feb, 2017 till 20th feb, 2017 ie 20 days. How can I calculate this?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 06:51:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/233914#M69512</guid>
      <dc:creator>ASISH_9</dc:creator>
      <dc:date>2017-01-10T06:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of days between the beginning of the month to a date within the same month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/233915#M69513</link>
      <description>&lt;P&gt;are the dates you are calculating between values in fields? Are they the range from the time picker?&lt;/P&gt;

&lt;P&gt;If they are values in fields, it'd be as simple as &lt;CODE&gt;|eval daysBetween=round((time2-time1)/86400,0)&lt;/CODE&gt; given that the time fields are in epoch, if not, you'll need to do some more evaling with either &lt;CODE&gt;strftime&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If the values are from the time picker, use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|gentimes start=-1 | addinfo | dedup info_min_time info_max_time 
          | eval daysBetween=round((info_max_time-info_min_time)/86400,2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:48:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/233915#M69513</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-01-10T14:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of days between the beginning of the month to a date within the same month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/573657#M199913</link>
      <description>&lt;P&gt;I have a report that runs every day and is doing calculations based on the number of days that have occurred so far.&amp;nbsp; After pulling my hair out and using a variety of techniques posted in these forums, I ended up with:&lt;/P&gt;&lt;P&gt;| eventstats dc(date_mday) AS daysInMonth&lt;/P&gt;&lt;P&gt;Unless i'm mistaken, the date_* fields are automatically generated in splunk (at least all the data i've seen has them) and this was the easiest and most reliable method I found.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 18:15:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/573657#M199913</guid>
      <dc:creator>sjbriggs</dc:creator>
      <dc:date>2021-11-04T18:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of days between the beginning of the month to a date within the same month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/573665#M199921</link>
      <description>&lt;P&gt;Assuming you've a field "date" with format "%Y-%m-%d", you can do something like this (run anywhere sample, replace first two lines with your base search)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval date="2017-02-20" | table date | eval startOfMonth=relative_time(strptime(date,"%Y-%m-%d"),"@mon") | eval noOfDays=round((strptime(date,"%Y-%m-%d")-startOfMonth)/86400+1)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Nov 2021 19:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-number-of-days-between-the-beginning-of-the/m-p/573665#M199921</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2021-11-04T19:14:37Z</dc:date>
    </item>
  </channel>
</rss>

