Splunk Search

Days Between Question

jhayIV
Engager

I am trying to determine the days between a static date and current date

in this query I added a the 2008r2 column with a static date - table Division Name OS _time | eval 2008r2="1/14/2020"|

I was unable to use a previous eval statement on this, I assume I dont have that column formatted properly
eval Days=round((2008r2(now(),"@d")-relative_time(2008r2,"@d"))/86400,0)

0 Karma

somesoni2
Revered Legend

Use like this

...table Division Name OS _time | eval 2008r2="1/14/2020"| eval Days=round((relative_time(now(),"@d")-relative_time(strptime('2008r2',"%m/%d/%Y"),"@d"))/86400,0) 

Basically, you need to convert your string date to epoch format so that you can do mathematical operation with current time now() which is in epoch. (the relative_time function also only accepts epoch value).

0 Karma

woodcock
Esteemed Legend

We need to see sample event data and your full search.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...