Splunk Search

Find number of days between date and now()

tkwaller_2
Communicator

Hello
trying something I assume is pretty easy just cant get it right for some reason.
I have a field called "Due Date" formatted as "%Y-%m-%d %H:%M:%S.%6N"
What I would like to do is find the number for days remaining between that date and today.

I assumed they both needed to be the same format so I tried to convert now() to the same format but that doesnt work, I assume thats by design since its a special field. I also tried converting my timestamp to the now() format but that didnt work either. Also was trying to convert to epoch to see if that helps but the same issue, format.

| eval dateDue=strptime('Step Due Date', "%Y-%m-%d %H:%M:%S.%6N")
| eval today=strftime(now(), "%+")

Still working on it but any assistance would be appreciated

0 Karma
1 Solution

493669
Super Champion

try this:

| eval dateDue=strptime('Step Due Date', "%Y-%m-%d %H:%M:%S.%6N")| eval days = round((now()-dateDue)/86400)

View solution in original post

493669
Super Champion

try this:

| eval dateDue=strptime('Step Due Date', "%Y-%m-%d %H:%M:%S.%6N")| eval days = round((now()-dateDue)/86400)

tkwaller_2
Communicator

Knew I was doing something off just a bit.
thanks!

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...