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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...