Dashboards & Visualizations

Calculate number of days between two days

Path Finder

Hi! I am trying to get a duration of the project by calculation the number of days between today and the project submit date. They are both in the same format (mm/dd/yy), but there are no results.  What am I doing wrong?

| eval "Project Submit Date"=strftime(strptime(project_submit_date,"%Y-%m-%d %H:%M:%S"), "%m-%d-%y")
| eval today=strftime(now(), "%m-%d-%y")
| eval "Duration"=(today-'Project Submit Date')/86400

Thank you very much!

Labels (1)
• panel

Tags (1)
1 Solution
Builder

The problem is you are converting an epoch time back into text before performing your delta between the two dates when you do a strftime after the strptime.  You can actually just use one eval to accomplish what you are looking for:

``| eval "Duration"=round(abs((relative_time(now(), "@d")-relative_time(strptime(project_submit_date,"%Y-%m-%d %H:%M:%S"), "@d"))/86400),0)``

Builder

The problem is you are converting an epoch time back into text before performing your delta between the two dates when you do a strftime after the strptime.  You can actually just use one eval to accomplish what you are looking for:

``| eval "Duration"=round(abs((relative_time(now(), "@d")-relative_time(strptime(project_submit_date,"%Y-%m-%d %H:%M:%S"), "@d"))/86400),0)``

Path Finder

Thank you!

Get Updates on the Splunk Community!

Index This | A sphere has three, a circle has two, and a point has zero. What is it?

September 2023 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Build Scalable Security While Moving to Cloud - Guide From Clayton Homes

Clayton Homes faced the increased challenge of strengthening their security posture as they went through ...

Mission Control | Explore the latest release of Splunk Mission Control (2.3)

We’re happy to announce the release of Mission Control 2.3 which includes several new and exciting features ...