Work with DateTime item

Hey there,
I need help for OH3:
I have an item:

DateTime    CalDav_Date 	    "Datum der Abholung [%1$td.%1$tm.%1$tY]"    <calendar>

I would like to calculate how many days left:

var int Termin_Abfall = (CalDav_Date.state as DateTimeType).getDayOfYear - now.getDayOfYear

I think somebody can help me :smiley:

i cannot look it up right now, but I think its easy to convert to epoch time to run the calculation

You almost never need to go down to getting epoch.

And in Rules DSL never force a value’s type, especially don’t force it to be a primitive unless absolutely necessary. It can add minutes to the amount of time it takes to parse the rules.

var Termin_Abfall = (CalDav_Date.state as DateTimeType).getZonedDateTime.getDayOfYear - now.getDateOfYear