On this page



Use case

Update a number field with the difference in days between two dates obtained from two Date Picker fields.


Prerequisites

Remove this section, if no prerequisites are needed.



Create a Number custom field

Name: Time Difference


Add it to the screens of your choice.








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.


If you prefer to use our parsing mode, you can set the expression editor to General mode and create an expression as follows:

%{({issue.cf10001}-{issue.cf10002})/1000 /60 /60 /24}


Do not forget to surround the operation with an additional %{}






Add more steps according to your needs.




Related use cases




JWT feature

Workflow function

Update fields

Parser functions
Labelused to mark a use case as staff pick
Use case descriptionUpdate a number field with the difference in days between two dates obtained from two Date Picker fields.
Complexity






Status
Tech review

Style guide