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!

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...