One time automation?

Hi guys,
i am looking to run an automation only one time, is that possible?

Let say i have an event and i want to send info one time on 15.5.24 and than stop.
At the moment i am thinking of running a task each day and only run it if the day is 15.5.24.

Is there a better way to do that to create one time automation?

Odd use-case.

Hereā€™s what I would do, let me know if this works for you.

  1. Add a DateHelper. Use the Get current Date function I used YYYY-MM-DD and my local timezone.

  2. Add a Code Piece.

  3. Add key ā€œcurrentDateā€ and variable pass through for the value from DateHelper.

  4. Click on fullscreen to expand the code screen.

  5. Click ā€œadd npmpackageā€ and add the package below as a dependency.

date-fns
  1. Add this code into the code body:
import { isSameDay, parseISO } from 'date-fns';

export const code = async (inputs: any): Promise<boolean> => {
  // If inputs.currentDate is provided and is a valid date, use it.
  // Otherwise, use the current system date.
  const currentDate = inputs?.currentDate ? new Date(inputs.currentDate) : new Date();

  // Define the target date as a string and parse it to a Date object
  const targetDateString = '2024-05-11';
  const targetDate = parseISO(targetDateString);

  // Check if the current date is the same day as the target date
  return isSameDay(currentDate, targetDate);
};

  1. Add a branch for True/False. If true, execute your automation. If False, do whatever you want.

I would certainly test this before the date in question to ensure it is working the way you want.

Thanks man, appreciate the help.
I know how to create automation like this (-:

My question was if there some a better way to do that, as i might need to do it again in the future.

What I would do is ask ChatGPT for a cron expression on your date and use that for the schedule piece, here is the answer:

To create a cron expression that runs only on May 15, 2024, you can set it up to trigger at a specific time of day. For example, if you want it to run at 8:00 AM on that date, the cron expression would be:

0 8 15 5 ? 2024

Hereā€™s how the expression breaks down:

  • The first 0 stands for the minute (0 minutes past the hour).
  • The 8 stands for the hour (8 AM).
  • The 15 stands for the day of the month (15th).
  • The 5 stands for the month (May).
  • The ? is used in the day-of-week field to denote no specific value (since day of the month is already specified).
  • The 2024 stands for the year.

This expression will ensure the task runs at 8:00 AM on May 15, 2024, and not on any other date or time. If you need it to run at a different time, adjust the hour and minute fields accordingly.

Kr Bram

4 Likes

You rock, that promising (-:
I will give it a try.

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