How to find out number of days between two dates?

Hi, I need to subtract dates. At Excel I can simply subtract two cells with dates as they are numbers.
Similarly Ineed to add number of days to one date to get another date.

Thank you for script or any idea.


Hi Josef, I’ve solved this like

var D1= doo.model.<[D1 (D1)]>;
var D2 = doo.model.<[D2 (D2)]>;
doo.model.<[DIff (dIff)]>.setValue(Math.ceil((D2.value-D1.value)/3600/24/1000));

hope this works for you

1 Like

Hi James. Thank you for your help. But it is not working even when I replaced ceil for cell.

Please, give a look at enclosed picture. Thank you.


Hello Josef,

This works for me. :slight_smile:

let d1 = doo.model.<[Date (date)]>.value;
let d2= doo.model.<[Date 2 (date2)]>.value;

doo.model.<[date 3 (date3)]>.value = Math.round((new Date(d2).valueOf() - new Date(d1).valueOf())/1000/60/60/24);

(Date 3 => Number data type)

Have a nice day.

With kind regards,

Hello Soňa.
Thank you for your answer. But I cannot believe it does not work at my table.

Please see the picture:

The mistake is the same as it was for code from James.

With kind regards,


Hello Josef,

Have you renamed the field names according to your application? Please check and if it still doesn’t work, please let me know at

Thank you

With kind regards,