Splunk Search

how to calculate days between two dates and also how to calculate only business date?

chandanimishra
New Member

| eval duedate1 = strftime(strptime(duedate,"%Y-%m-%d"),"%Y-%m-%d %H:%M:%S")
| eval current = strftime(now(),"%Y-%m-%d %H:%M:%S")
| eval daysdiff=round((current-duedate1)/86400,0)
| table current duedate1 daysdiff

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Differences between timestamps must be calculated using the epoch form of timestamp. Try this:

| eval duedate1 = strptime(duedate,"%Y-%m-%d")
| eval current = now()
| eval daysdiff=round((current-duedate1)/86400,0)
| eval today = strftime(current, "%Y-%m-%d %H:%M:%S")
| table today duedate daysdiff
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...