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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

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 GA in US-AWS!

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