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!

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...