Dashboards & Visualizations

Calculate number of days between two days

yvassilyeva
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)
Tags (1)
0 Karma
1 Solution

dmarling
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)

 

 

If this comment/answer was helpful, please up vote it. Thank you.

View solution in original post

dmarling
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)

 

 

If this comment/answer was helpful, please up vote it. Thank you.

yvassilyeva
Path Finder

Thank you!

0 Karma
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 ...