Trying to substrata one date from another

Posted by Rollbase User on 06-Feb-2013 13:24

Need your help with a formula I'm trying to subtract one date from another so I can get a total days difference between two dates Formula: var d = new Date("{!ler_date#iso}"); var c = new Date("{!actual_time_of_arrival#iso}"); return d.getDate() - c.getDate(); All I get is NULL

All Replies

Posted by Admin on 06-Feb-2013 14:44

Hello,



You should not use #iso when setting a date.



I would do it this way:



var d = new Date("{!ler_date}");

var c = new Date("{!actual_time_of_arrival}");

return (d.getTime()-c.getTime())/24/3600/1000;



Posted by Admin on 07-Feb-2013 01:18

Romain,



Thank you for your help! It worked.



Small note to all who is just starting with programming Rollbase -

I was trying to subtract day from one related Object from another day from another object

For that I created template field and imported related date in Java Script format (#js)

{!R62551360.ler_submission_date#js}



Only then I was able to get this formula working.

This thread is closed