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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...