On this page
Use case
Update a number field with the difference in days between two dates obtained from two Date Picker fields.
Prerequisites
Configuration
Add the post function Update fields to the transition of your choice.
Target issue*
Select current issue
Fields
Field*
Select Time Difference, the field previously created
Value*
Select Set field value manually (parser expression) and enter the following expression with the expression editor in Jira expression mode:
((new Date(issue?.customfield_10043 + "T00:00:00").getTime() - new Date(issue?.customfield_10040 + "T00:00:00").getTime())) / 1000 / 60 / 60 /24
Replace the field codes of the expression with the ones of your Date Picker fields.
With the current configuration, this expression will return the number of days between the first date and the second one. In order to display the number of hours, remove /24 from the expression.
Related use cases
If you still have questions, feel free to refer to our support team.