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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

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 ...