Sending Emails on specific dates

Hi guys,

I'm very new to Node-Red and using it within Home Assistant. I am wanting to setup an automated Email that gets sent on a specific calculated day every month. I will try and break this down the best I can:

Email needs to get sent 10 working days before the same day a month later
Email cannot be sent on a weekend or a public UK holiday

So for example if the last Email sent was on the 20/04/2023, the next Email would need to be sent on the 5/05/2023. This is because the 20/05 is a Saturday, so 10 working days (Mon to Fri) would be the 8th, but the 8th is a Bank Holiday so cant be sent then either, so would then need to be sent on the Friday prior being the 5th.

I realise that Easter is a problem due its flexiable date.

I look forward to peoples responses to this.
Thanks
James

Hi James, welcome to the forum.

It looks like you will be needing some date based arithhmetic - add a calendar month, subtract 9 days.
node-red-contrib-moment might be useful for this.
Then keep subtracting a day until your proposed email date is not a saturday, sunday or bank holiday.

You can obtain a list of past and future bank holidays at https://www.gov.uk/bank-holidays.json.
Retrieve it with an HTTP request node set to return a JSON object.
It has sections "england-and-wales", "scotland" and "northern-ireland".
You say you want to exclude UK holidays so I guess you will need to compare your proposed email date with all three sections.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.