How to Retrieve Campaign Data From MailerLite and Send It to Google Sheets

Опубликовано: 17 Июнь 2026
на канале: DigitalSpring
40
0

Monthly email marketing reports don't have to take hours to prepare. With this simple Make.com automation you can save time every month.

Here's your JS code:

const now = new Date();
const currentMonth = now.getMonth() + 1;
const currentYear = now.getFullYear();

const prevMonth = currentMonth === 1 ? 12 : currentMonth - 1;
const prevYear = currentMonth === 1 ? currentYear - 1 : currentYear;

const firstDayPrevMonth = new Date(prevYear, prevMonth - 1, 1);
const lastDayPrevMonth = new Date(prevYear, prevMonth, 0);

function pad(n) {
return n.toString().padStart(2, '0');
}

function format(date) {
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
}

return {
startDate: format(firstDayPrevMonth),
endDate: format(lastDayPrevMonth)
};

If you have any questions, let me know at   / kosta-nikolov