In the workflow below I’m using a Java Script code to find the day of the week of a date.
It turns out that if I put the date in the code statically it works perfectly, if I search from the previous node it returns the date that comes from the previous node instead of returning the day of the week as it happens statically.
** This one below works wrong**
//Retorna o dia da semana entre 0 e 6
var day = new Date (‘data-buscada’).getDay();//Array para atribuir o dia da semana junto a função .getDay()
const weekday = [“Domingo”, “Segunda-feira”, “Terça-feira”, “Quarta-feira”, “Quinta-feira”, “Sexta-feira”, “Sábado”];//Atribui o nome do dia da semana à propriedade ‘day_today’
items[0].json.day_today = weekday[day];return items;
Este abaixo retorna da forma que quero, mas, apenas de forma estática
//Retorna o dia da semana entre 0 e 6
var day = new Date (‘2023/03/08’).getDay();//Array para atribuir o dia da semana junto a função .getDay()
const weekday = [“Domingo”, “Segunda-feira”, “Terça-feira”, “Quarta-feira”, “Quinta-feira”, “Sexta-feira”, “Sábado”];//Atribui o nome do dia da semana à propriedade ‘day_today’
items[0].json.day_today = weekday[day];return items;