0

How to get workdays between dates using javascript function from a spreadsheet

function dateTest() {

    var template=SpreadsheetApp.openById('280337105')

    var test = template.getSheetByName('Consultants');

    var database =SpreadsheetApp.getActive().getSheetByName('Prospect33');

    var startDate = database.getRange('C7').getValue();

    var endDate = database.getRange('E7').getValue();

    test.getRange('M7').setValue(startDate);

    test.getRange('N7').setValue(endDate);

    }
Rubén
  • 34,714
  • 9
  • 70
  • 166
  • Have you looked at [this answer](https://stackoverflow.com/a/28425663/4717755) ? – PeterT Jan 24 '19 at 19:55
  • @PeterT yes i have but when tried gives the error moment undefined – austine mwasi Jan 25 '19 at 13:43
  • Austine, have you included the moment.js lib as a dependency to your project? – Patrick Hund Jan 25 '19 at 13:48
  • The link I provided requires using the `momentjs` package. Using some sort of packaged date/time manipulation functions is [highly reccommened](https://stackoverflow.com/a/1214753/4717755). Pick your package and give it a try. – PeterT Jan 25 '19 at 14:20
  • How much research have you done? There are dozens of questions like this on StackOverflow. Look at: [Number of working days between two dates in Google Apps Script](https://stackoverflow.com/questions/29350307/). – Tedinoz Jan 26 '19 at 02:06
  • Possible duplicate of [How do I calculate number of given weekday between range using Moment JS?](https://stackoverflow.com/questions/29090867/how-do-i-calculate-number-of-given-weekday-between-range-using-moment-js) – Patrick Hund Jan 26 '19 at 20:45

0 Answers0