Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By springhigh
#812826
Hi
I was wondering if anyone has managed to replicate the Excel DAYS360 function successfully in processmaker.
I am trying to replicate an excel spreadsheet (accounting methodology) , which uses this to calculate the number of days between 2 dates dates based on this.
Any advice would be much appreciated.
thanks
User avatar
By amosbatto
#812873
Here is an example in JavaScript:
Code: Select all
//calculate the difference in days based on a 360 day calendar:
function calculateDays360(startDate, endDate) {
  if (startDate == '' || endDate == '') {
    $("#difference").setValue('');
    return false;
  }
  
  var oStart = moment(startDate);
  var oEnd   = moment(endDate);
  
  var diffDays = (oEnd.year() - oStart.year()) * 360;
  diffDays += (oEnd.month() - oStart.month()) * 30;
  diffDays += oEnd.date() - oStart.date();

  $("#difference").setValue(diffDays);
  return diffDays;
}
  
$("#startDate").setOnchange( function(newVal, oldVal) {
  calculateDays360( newVal, $("#endDate").getValue() );
});

$("#endDate").setOnchange( function(newVal, oldVal) {
  calculateDays360( $("#startDate").getValue(), newVal );
});
 
Here is a sample form that shows how to use it:
(4.75 KiB) Downloaded 266 times

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]