Day of the week of a date from a previous node

What’s the easiest way of finding the day of the week of a given date from a previous node?
My trigger is a new Pipedrive activity, and I want to find out if the activity is scheduled for the weekend. If so, I want to push it to Monday.

Hey @amit,

Have you already tried $node["node_name"].json.value? or instead of a previous node do you mean a previous run of the workflow?

Hi Jon! Thank you for responding.

I mean the following setup.
The trigger node is a Pipedrive Activity Created.
image

I want to check if due_date (screenshot below) falls on a weekend.

image

In that case you might be able to just use item.json.due_date but it depends on if there is anything else in the data before it.

As a quick concept you can do something like…

for (item of items) {
  let date = DateTime.fromString(item.json.due_date, "yyyy-MM-dd");
  if (date.weekday === 6 || date.weekday === 7) {
    item.json.weekend = true;    
  } else {
    item.json.weekend = false;
  }
}

return items;

Which will return something like the below if the day of the week is a saturday or sunday.

[
  {
    "due_date": "2022-04-09",
    "weekend": true
  }
]