Question

Automatically calculated field

  • 29 April 2024
  • 2 replies
  • 44 views

Badge +2

I have leave start date , leave end date and duration fields I want the duration field to be automatically calculated from start and end fileds like this (leave end date- leave start date)+1 how can i do this?


2 replies

Userlevel 6
Badge +16

Hi @Alaa Moussa 

It quite simple. Use create a form rule. You will need to use this formula datediff()
Is the duration field a Text or Number field?

What should the duration be for this example? Start Date (May 1) and End Date (May 4)
4-1 = 3. 3 days or 4 days. You stated that it should be 4. 

 

On your form, insert the Start Date (Date), End Date (Date) and the duration fields.

Create a new Form Rule.
Add 2 conditions - Start Date is filled AND End Date is filled.

 

Add the THEN outcomes.
Set Duration field (Number type) to the value of the formula

dateDiff("TotalDays",[Form].[Start Date],[Form].[End Date])

If you need to add 1 more day…

dateDiff("TotalDays",[Form].[Start Date],[Form].[End Date]) + 1

 

If the Duration field is Text, you need to add the convertToString() function

convertToString(dateDiff("TotalDays",[Form].[Start Date],[Form].[End Date]))

 

Summary

 

Userlevel 5
Badge +20

Hi @Alaa Moussa 

Did this response help solve your question? 

Reply