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 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...