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!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...