Days calculation

Hi! I wish to calculate the number of days elapsed between two days without success. Can anyone help and explain how to do it.


In case you have 2 date questions in your questionnaire date1 and date2 you can use them in the following snippet (date1 - date2)?.TotalDays. It will give you total days between dates.

Couple of things to note, since any of the date1 or date2 might have no answer result of the expression might be null that is why here is null safe navigation operator after ). Also TotalDays has double type, not integer and might return negative value if date2 is after date1, in case you need only positive number of days you can use Math.Abs function in the following way Math.Abs((date1 - date2).Value.TotalDays).


See also the manual:

1 Like

Thanks to both of you. Both info have been useful. It has been of great help.