Rules: get the month of a year

I’m searching for a way to find the month of a year.
There is a solution for dayOfWeek and dayOfMonth but no monthOfYear.
Any tip is welcome.

Which version of openHAB?

In JavaTime (i.e. openHAB from 3.0.0) a simple now.getMonth() will provide the name of the current month, while now.getMonth().getValue will provide the number (1 to 12)

In Joda Time (i.e. openHAB up to 2.5.12) you willl have to use now.getMonthOfYear() (this will provide number (1 to 12). and now.getMonthOfYear().getAsText() will provide the name of the month :slight_smile:

2 Likes

Thanks Udo,
I have OH3.
With cron “0 59 23 L * ? *” if have the solution for updating totals at the end of every month.