Schedule on "last day of month"

Posted on
Wed Feb 14, 2024 1:54 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Schedule on "last day of month"

Hi all,

is there a way to set a schedule for last day of month? I know I can set the exact day (30,31) but every month is different and I need the schedule on the last day (in February on the 28th, 9th this year) :D

Thanks
Marco

Posted on
Wed Feb 14, 2024 6:01 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Schedule on "last day of month"

Not with the schedule date options, but it is possible to do it. There's an elegant approach in this other thread along with a couple other suggestions. I think this one is best.

Set your condition on a schedule run every day to fire if Python returns true. Check to see if tomorrow is in a different Month than today:

Code: Select all
import datetime

current_date = datetime.datetime.today()
nextday_date = datetime.datetime.today() + datetime.timedelta(days=1)
if (current_date.month != nextday_date.month):
    return True
else:
    return False


I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Feb 14, 2024 8:05 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Schedule on "last day of month"

Thanks a lot, but getting an error:

Code: Select all
return True
    ^^^^^^^^^^^
SyntaxError: 'return' outside function


Is this anything new in 3.11?

Posted on
Wed Feb 14, 2024 9:24 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Schedule on "last day of month"

Did you paste the entire code block as it appears? I'm not seeing that error. This isn't anything new with Python 3.11.

What version of Indigo are you using?

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Feb 14, 2024 9:30 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Schedule on "last day of month"

Also, that code does NOT go into an action for the schedule. It goes into the Conditions tab.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Feb 14, 2024 9:43 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Schedule on "last day of month"

Good call Joe. I hadn't considered that as a possibility -- but with that -- the error make more sense.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 8 guests