Splunk Search

How to calculate the number of days from a create date to the current date?

itsmevic70
Explorer

 

 

index=servicenow assignment_group_name="security" status=*
| stats count by number,status,group_name,created_on

 

 

The above query will produce the following:

Splunk Days Inbetwen Calculation.JPGI need to calculate the number days from the "created on" date shown above in the example to the current date.  

Any help with this is greatly appreciated.

Labels (3)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Add

| eval days=round((now() - strptime(created_on, "%d-%b-%y %H:%M:%S")) / 86400, 0)

to calculate days - this rounds to 0 decimal places. Change as required or use floor() to round down if wanted.

View solution in original post

Tags (1)

itsmevic70
Explorer

Thank you.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Add

| eval days=round((now() - strptime(created_on, "%d-%b-%y %H:%M:%S")) / 86400, 0)

to calculate days - this rounds to 0 decimal places. Change as required or use floor() to round down if wanted.

Tags (1)
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...