• Resolved troxx

    (@troxx)


    Hello, I need a simple calculation – user picks a date and desired service, to calculate when the service would be finished. Simple “cdate(fieldname1+fieldname7)” BUT – how can I omit Saturdays and Sundays from the calculation?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @troxx,

    I’ll assume the fieldname1 is a date field, and the fieldname7 a number field with the amount of working days, a simple way to implement it would be:

    (function(){
       var d = new Date(fieldname1*86400000), c = fieldname7;
       while(0< c)
       {
          d.setDate(d.getDate()+1); 
          if(d.getDay() != 0 && d.getDay() != 6)
          c--;
      }
      return cdate(d.valueOf()/86400000);
    })()

    Best regards.

    Thread Starter troxx

    (@troxx)

    It works! Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Calculating date without weekends’ is closed to new replies.