Select to view content in your preferred language

Calculate Number of Days Between Two Dates

2267
3
Jump to solution
05-16-2023 11:30 AM
icf_Eric_Link
Regular Contributor

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.

0 Kudos
1 Solution

Accepted Solutions
icf_Eric_Link
Regular Contributor

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)

View solution in original post

0 Kudos
3 Replies
MobiusSnake
MVP Regular Contributor

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.

0 Kudos
icf_Eric_Link
Regular Contributor

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)

0 Kudos
SIG-EscutismoCNE
Emerging Contributor

Hello,

 

Can anyone help me?

I have a field called "data_de_in_cio_da_actividade" (default: format-date(${wsdatetime},'%H:%M') and another one called "inserir_data_de_submiss_o" (default: now())

I need to receive a message when the field "inserir_data_de_submiss_o" is less than 14 days from the field "data_de_in_cio_da_actividade"

Already tried this expression but without success

date(${data_de_in_cio_da_activity}) - date(${inser_data_de_submiss_o}) < 14

 

Thanks for your attention,

 

 

0 Kudos