Could you help me please? I need to compare two dates to generate an if condition when it expires. My idea is to send an email to the person involved when today's date is greater than the date in the elements [16]. I broke my head and I couldn't compare with each other, it only works with the same because it is comparing text. An example below:
function sendmailAtualizarFollowup(){
var app = SpreadsheetApp;
var gmail = GmailApp;
var spreadsheet = app.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName('Cópia de Dados');
var values = sheet.getRange("B2:AR").getValues();
var now = new Date();
// var now = new Date();
// var nowString = Utilities.formatDate(now, 'TimeZone', 'dd/MM/yyyy');
// Logger.log(now);
values.map(function(elem,ind,obj){
if(elem[0] != ""){
var vencimento = new Date(elem[16]);{
// var vencString = Utilities.formatDate(vencimento, 'timeZone', 'dd/MM/yyy');
// Logger.log(vencString);
if(elem[11] != ""){
if(now.toDateString() == vencimento.toDateString()){ //Here's my trouble
gmail.sendEmail(elem[38], "Subject -> "+elem[0], "Example: "+elem[5]+" "+elem[7]+", sob responsabilidade do(a) "+elem[10]+". A data de emissão do relatório contendo este evento é "+elem[3].toDateString()+", e o vencimento original proposto pela área é "+elem[11].toDateString()+". A situação do ponto é: Controle "+elem[22]+". Os detalhes do apontamento estão disponíveis no link: "+elem[20]+". Esta é uma mensagem automática.");
}
}
}})};