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!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...