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!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...