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!

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...

Enterprise Security Content Update (ESCU) | New Releases

In April, the Splunk Threat Research Team had 2 releases of new security content via the Enterprise Security ...