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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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