Calculate date difference from two fields

Confluence User - 25 Nov, 2020

Hi everyone,

How if I want to calculate date difference from two fields (im using text field not date picker)?


eg:

Date start: 2020-08-17

Date finish: 2020-11-25

Duration in days: ______

date

4


26 Nov, 2020
confluenceUser
confluenceUser

Use Google as your first choice, for example type "Joget calculate date dx" and the first result is your answer.

26 Nov, 2020
confluenceUser
confluenceUser

I already try this one before but both my date is not from date picker but text fields so the output did not show up.

26 Nov, 2020
confluenceUser
confluenceUser

Here are more information here and Javascript API.

02 Dec, 2020
confluenceUser
confluenceUser

So I use custom html and code like this but still nothing happen. Can you please help me to check which part is wrong? I've been working on these for a few days and keep changing my code also cannot. 

The date format is dd/mm/yyyy.

<script type="text/javascript">

$( function(){
    $('input[name="PIC_joinDate_bottom1"], input[name="dateSubmit_bottom1"]').change( function(){
    var start = new Date($('#PIC_joinDate_bottom1').val()); 
    var end = new Date($('#dateSubmit_bottom1').val()); 
    var Difference_In_Time = end.getTime() - start.getTime(); 
    var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24); 
    $('input[name=PIC_duration_bottom1]').val(Difference_In_Days);
    });

});
</script> 


RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print