<?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: Date Conversion in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338425#M159704</link>
    <description>&lt;P&gt;Hi  raghu0463,&lt;BR /&gt;
I'm not sure of one thing: in your select it seems that there are three fields in Diff (day, ga.Initial_L1_Decision_Date, Close_date), are really three or not?&lt;BR /&gt;
if you have two dates, try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| eval "Days Since Initial L1 Decision"=(strptime(ga.Initial_L1_Decision_Date,"%m/%d/%Y %H:%M:%S")-strptime(Close_date,"%m/%d/%Y %H:%M:%S"))/3600/24
| table your_fields "Days Since Initial L1 Decision"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I don't know time format of your dates, if they are wrong, modify the ones I used.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 02:54:47 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2020-09-30T02:54:47Z</dc:date>
    <item>
      <title>Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338423#M159702</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
How to convert this SQL statement to SPL pls &lt;/P&gt;

&lt;P&gt;select DateDiff(day, ga.Initial_L1_Decision_Date, Close_date) as [Days Since Initial L1 Decision] from table&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:06:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338423#M159702</guid>
      <dc:creator>raghu0463</dc:creator>
      <dc:date>2020-09-29T15:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338424#M159703</link>
      <description>&lt;P&gt;If both the dates are in epoch format, you can do like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;..| eval "Days Since Initial L1 Decision"=round(abs('Close_date'-'ga.Initial_L1_Decision_Date')/86400)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If they're not epoch, you need to convert them to epoch for calculation, like this (update the timeformat in strptime according to yours)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;..| eval "Days Since Initial L1 Decision"=round(abs(strptime('Close_date',"%Y-%m-%d %H:%M:%S")-strptime('ga.Initial_L1_Decision_Date',"%Y-%m-%d %H:%M:%S"))/86400)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 13:50:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338424#M159703</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-31T13:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338425#M159704</link>
      <description>&lt;P&gt;Hi  raghu0463,&lt;BR /&gt;
I'm not sure of one thing: in your select it seems that there are three fields in Diff (day, ga.Initial_L1_Decision_Date, Close_date), are really three or not?&lt;BR /&gt;
if you have two dates, try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| eval "Days Since Initial L1 Decision"=(strptime(ga.Initial_L1_Decision_Date,"%m/%d/%Y %H:%M:%S")-strptime(Close_date,"%m/%d/%Y %H:%M:%S"))/3600/24
| table your_fields "Days Since Initial L1 Decision"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I don't know time format of your dates, if they are wrong, modify the ones I used.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:54:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338425#M159704</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-30T02:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338426#M159705</link>
      <description>&lt;P&gt;is that strptime is for single field or do i need to apply for both together ?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:11:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338426#M159705</guid>
      <dc:creator>raghu0463</dc:creator>
      <dc:date>2017-07-31T15:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338427#M159706</link>
      <description>&lt;P&gt;You need to apply strptime for each field which you want to convert from string to date/epoch.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:26:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Conversion/m-p/338427#M159706</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-31T15:26:36Z</dc:date>
    </item>
  </channel>
</rss>

