Splunk Search

Difference between two dates

ncbshiva
Communicator

I have a log that has
Start date=2003-11-20 00:00:00,End date=2079-06-06 00:00:00.
I want to calculate the difference between the Enddate and Startdate, and display the difference in both days and in years.

Please help me

Tags (1)
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

For days you can do this:

...  | eval days = round((strptime(Enddate, "%F %T") - strptime(Startdate, "%F %T")) / 86400)

For years it depends on what you want to see.

Get Updates on the Splunk Community!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

Stay Connected: Your Guide to October Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...