zero6pak avatar

Enumeration of dates between 'startdate' and 'enddate' using Custom function

zero6pak

Published: 12 Jan 2019 › Updated: 12 Jan 2019Enumeration of dates between 'startdate' and 'enddate' using Custom function

Enumeration of dates between 'startdate' and 'enddate' using Custom function

frequently working schedule

we need to view dates between startdate and enddate.

1.jpg
[date type data]

2.jpg
[formular]

we can extract dates from working duration without adding any repeated codes.

[script]

function dtr( formula ){
if (typeof formula.map === "function"){
return formula.map(dtr);
}else if(formula){
return WriteTermDates(formula);
}
}

function WriteTermDates(d) {

var ss1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SHEET");

var testDate = new Date("1900/1/1");
var startDate = new Date(testDate.getDate()+parseInt(d.substring(0,5)-25569)24 * 60 * 60 * 1000);
var endDate = new Date(testDate.getDate()+parseInt(d.substring(5,10)-25569)
24 * 60 * 60 * 1000);

var values = "";

while(startDate.getDate() <= endDate.getDate()) {

//   Logger.log(Utilities.formatDate(startDate, "GMT", "MM-dd"));

values += Utilities.formatDate(startDate, "GMT", "MM-dd") + ", ";

startDate.setDate(startDate.getDate() + 1);

}
return values;
}

Leave Enumeration of dates between 'startdate' and 'enddate' using Custom function to:

Written by

Read more #spreadsheet posts


Best Posts From zero6pak

We have not curated any of zero6pak's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From zero6pak