# Cronplus day/month specification

**URL:** <https://discourse.nodered.org/t/cronplus-day-month-specification/84544>\
**Category:** General\
**Created:** [15 January 2024 02:05 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544 "2024-01-15T02:05:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![xytsrm](https://avatars.discourse-cdn.com/v4/letter/x/6de8d8/32.png) [@xytsrm](https://discourse.nodered.org/u/xytsrm)\
**Post date:** [15 January 2024 02:05 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/1 "2024-01-15T02:05:32Z")

</div>

I have used the following specification: 0 45 23 \* DEC,JAN \*. The timer will fire every day at 2345 for December & January.  
I wanted to add specific days to December & January.  
For this specification: 0 45 23 6-31 DEC,JAN \*; the timer will fire between 6-31 DEC & JAN at 2345.

What I want is a timer that will fire at 2345 for 6-31 DEC & 1-6 JAN.  
I tried 0 45 23 6-31 DEC, 1-6 JAN \* but that is invalid.  
Do I need two timers?  
Timer1 0 45 23 6-31 DEC \*  
Timer2 0 45 23 1-6 JAN \*

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [15 January 2024 04:02 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/2 "2024-01-15T04:02:25Z")

</div>

Is there a reason two timers won't work? You can put two schedules in cronplus

---

<div class="post-metadata">

**Author:** ![xytsrm](https://avatars.discourse-cdn.com/v4/letter/x/6de8d8/32.png) [@xytsrm](https://discourse.nodered.org/u/xytsrm)\
**Post date:** [15 January 2024 04:16 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/3 "2024-01-15T04:16:48Z")

</div>

Absolutely not, I already have multiple timers (schedules). But it would he more convenient with a single timer for this application. Are you suggesting that there is no way to create a single timer with the specification I require?  
It could work if cronplus had an "OR" separator whereby the specification would read Timer1 OR Timer2 (as I defined Timers 1 & 2).

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [15 January 2024 07:28 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/4 "2024-01-15T07:28:56Z")

</div>

With _one_ expression, you'd always skip days 1-5. So you need to use two separate expressions, like you already posted initially.

But this can be solved with cron-plus as-is.

To treat both triggered events the _same_, you can set the same `topic` or `payload` on each task, whatever works best for you. Add a switch node that checks for that, and you're done. 😉

---

<div class="post-metadata">

**Author:** ![xytsrm](https://avatars.discourse-cdn.com/v4/letter/x/6de8d8/32.png) [@xytsrm](https://discourse.nodered.org/u/xytsrm)\
**Post date:** [15 January 2024 14:43 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/5 "2024-01-15T14:43:07Z")

</div>

Thanks kuema, cronplus options can be rather complex; I just wanted to make sure I wasn't missing something that would allow a single schedule to do the job. While I've used switch-nodes, I have a function-node with switch-statements. I was using the simple cronplus schedule 0 45 23 \* DEC,JAN \* and using a function-node to block 1-5 Dec and 7-31 Jan; it does the job, but it would be cleaner if it were done in cronplus.

It's too bad that cronplus doesn't have a "OR" separator for it's specification then, as I mentioned, the single schedule:  
0 45 23 6-31 DEC \* OR 0 45 23 1-6 JAN \* would work.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [15 January 2024 14:49 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/6 "2024-01-15T14:49:16Z")

</div>

Per se, that's not a restriction of cron-plus, it's simply not expressible via one cron statement.

I use cron-plus a lot (mostly the dynamic schedule feature), and had the same requirement of triggering one task (flow) by multiple schedules. The combination of payload and topic to _logically_ group them together has served me well, while keeping the expressions readable and manageable.

---

<div class="post-metadata">

**Author:** ![xytsrm](https://avatars.discourse-cdn.com/v4/letter/x/6de8d8/32.png) [@xytsrm](https://discourse.nodered.org/u/xytsrm)\
**Post date:** [15 January 2024 15:00 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/7 "2024-01-15T15:00:08Z")

</div>

I didn't mean to imply it was a restriction of cronplus; the "OR" separator would just be an additional feature that could be added.

While I probably setup cronplus with two schedules, I will still use the function-node date-filter because I trigger another action based on sunset, but I only want it to trigger on certain dates. Is there a way to restrict cronplus sunset triggers to specific dates?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [15 January 2024 16:01 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/8 "2024-01-15T16:01:11Z")

</div>

> [@xytsrm](#):
>
> Is there a way to restrict cronplus sunset triggers to specific dates?

None that I know of, it's either plain cron or "sun events".

I'm also using the chronos nodes. Besides cron and solar stuff, they offer some special nodes for time-based filters, switches, etc. Maybe you find them useful as well.

> **[node-red-contrib-chronos](https://flows.nodered.org/node/node-red-contrib-chronos)**
>
> Time-based Node-RED scheduling, repeating, queueing, routing, filtering and manipulating nodes

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 March 2024 16:02 UTC](https://discourse.nodered.org/t/cronplus-day-month-specification/84544/9 "2024-03-15T16:02:03Z")

</div>

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