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!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...