[✅ Solution] Trigger: on date == today

Hi friends, I’m asking here to save time.

I want to check a list of items daily, and if current date matches the item date, trigger a manual automation.

My question, how can I check current date against the item date regardless of year set.

I know I can run and then update the item date +12months but I wanted to see if there was an easy way to not check the year at all.

You can switch to a script filter to check the specific month and day - it would look like this for today’s date for example (10/17):

For easy copy/pasting it’s:

new Date().getDate() == 17 && new Date().getMonth() == 9

4 Likes

Thanks for the reminder.
I keep forgetting you can convert fields to scripts in Tape.

Adding a code snippet below so it can help someone in the future.

  • Update “America/Detroit” to your Timezone
  • Replace “MYDATEFIELD” with your items date
function checkDate(dateField) {
    // Get the current date
    const currentDate = new Date(); 

    // Convert the current date to Eastern Detroit Timezone
    const currentDateString = currentDate.toLocaleString("en-US", { timeZone: "America/Detroit" });
    const currentDateDetroit = new Date(currentDateString);

    // Extract the month and date
    const currentMonth = currentDateDetroit.getMonth();
    const currentDay = currentDateDetroit.getDate();

    // Parse the date field
    const dateToCheck = new Date(MYDATEFIELD);

    // Convert the date field to Eastern Detroit Timezone
    const dateToCheckString = dateToCheck.toLocaleString("en-US", { timeZone: "America/Detroit" });
    const dateToCheckDetroit = new Date(dateToCheckString);

    // Extract the month and date from dateField
    const checkMonth = dateToCheckDetroit.getMonth();
    const checkDay = dateToCheckDetroit.getDate();

    // Compare and return result
    return (currentMonth === checkMonth && currentDay === checkDay);
}
4 Likes