I am making an API call to retrieve tariff data that is entered on the platform, in my call I would like to offer users the possibility of entering a specific date from which to retrieve the data. What I manage to do for now is allow them to choose the data that has been modified and therefore entered on the platform for a certain number of days, but what I want to do is allow them to enter a specific date instead of the number of days, could you help me on this point? thanks in advance.
here is my code :
function subDaysFromDate(date,d){
// d = number of day ro substract and date = start date
var result = new Date(date.getTime()-d*(24*3600*1000));
return result
}
//Ask the question of number of days to retrieve and retrieve data (Tarif)
//Pose la question du nombre de jours à récupérer et récupère les tarifs
function GetAllTarifs()
{
try{
var ui = SpreadsheetApp.getUi();
var resultat = ui.prompt('Search Tarif from a date?').getResponseText();
//Logger.log(parseInt(resultat,10))
if (isNaN(parseInt(resultat, 10))) {
SpreadsheetApp.getUi().alert("You have to insert the number of days");
}
else
{
var nbdays=parseInt(resultat, 10)
SpreadsheetApp.getActiveSpreadsheet().toast("Search Tarif modified since " + nbdays + " days")
GetAllTarifsFrom(subDaysFromDate(new Date(),nbdays))
}
}
catch(e)
{
SpreadsheetApp.getUi().alert("Execution Error."+e);
}
}