- Go to the Data Model by clicking on the Data Model icon in the Builder Bar.
- Click on a model you’d like to add new properties to or, create a new model for your properties.
- Within the model settings, go to the Properties subview on the right.
- Create 2 new date properties, one as start_date and the other as end_date. If you already have 2 dates within your model that you want to subtract, use those instead.
- Create a number expression property on the same model. Within the expression field of the property you should set the following expression: var:end_date - var:start_date. Note that the smaller value is subtracted from the greater value. The properties should be selected from the Variable browser which is available by clicking on the Insert variable button.
- Save the property. Expression properties are automatically recalculated when changed. Go to the Grid of that Model in the Back Office, if no Grid exists for the Model one should be created.
- Add the new property's component to the view.
- Enter the required data so the property's calculation is executed.
- Check the expression's outcome.
Keep in mind, subtracting dates will return a numeric value of the smallest unit of the values, or simply put: Subtracting date properties will return the outcome in days whereas subtracting date time properties will return the answer in seconds.
Example of difference in days
Outcome: 2019-07-10 - 2019-07-06 = 4
Example of difference in seconds
Outcome: 2019-07-10 12:00:00 - 2019-07-10 08:00:00 = 14400(To convert this to hours, multiply by 3600)