Splunk Search

How to find the number of days between a certain date field and today?

nspatel
Explorer

Hi Everyone,

I have a field called 'ddate'. This field is setup in the 'yyyy-MM-dd hh:mm:ss' format. I would like to know how many days ago that date was from today.

Data looks like this:
ddate="2014-08-18 09:07:47"

I need this in the end to be a number. Any idea? Thanks!

Tags (2)
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Something like this?

... | eval ddate_epoch = strptime(ddate, "%Y-%m-%d %H:%M:%S") | eval diff_seconds = now() - ddate_epoch | eval diff_days = diff_seconds / 86400

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

Something like this?

... | eval ddate_epoch = strptime(ddate, "%Y-%m-%d %H:%M:%S") | eval diff_seconds = now() - ddate_epoch | eval diff_days = diff_seconds / 86400

nspatel
Explorer

Ah I see what I was doing wrong now! Thank you so much Martin!!!!!!!

0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...