# Calculate Number of Days Between Two Dates

871
2
05-16-2023 11:30 AM
New Contributor III

Hello, I've got a form that is tracking usage of equipment.  I would like to have the user input a start date and end date and have the form calculate the number of days between the two dates.  Does anyone have an idea of an approach for doing this?  Thanks in advance.

1 Solution

Accepted Solutions
New Contributor III

Thanks!  So I found the doc after I posted and tested it out and it didn't quite work. I did however get the minutes spent for lunch formula to work.  Much appreciated for your response.

int((decimal-date-time(\${lunchends}) - decimal-date-time(\${lunchstarts})) * 24*60)

2 Replies
MVP

Here's an excerpt from the S123 Formulas doc:

Calculations can be used with the responses in date fields. This calculation estimates the number of years between a date entered and today, ideal for calculating somebody's age:

int((today() - \${birth_date}) div (1000 * 24 * 60 * 60 * 365.25))

Replacing today and birth_date with your two questions and removing 365.25 from the numbers would probably do it, but I haven't tested it.

New Contributor III

Thanks!  So I found the doc after I posted and tested it out and it didn't quite work. I did however get the minutes spent for lunch formula to work.  Much appreciated for your response.

int((decimal-date-time(\${lunchends}) - decimal-date-time(\${lunchstarts})) * 24*60)