Beginner -> rule to get a date and a string and put it into 1 item


I dry o get from a calendar item only 2 parts of the string into a new item.
i have the caldav items:
String CalDav_MuellkalName1 “Mülltonne [%s]” { caldavPersonal=“calendar:Muellkal type:EVENT eventNr:1 value:NAME” }
DateTime CalDav_MuellkalDate1 “Datum der Abholung [%1$td.%1$tm.%1$tY]” { caldavPersonal=“calendar:Muellkal type:EVENT eventNr:1 value:START” }

with the result
CalDav_MuellkalName1: "blaue Tonne"
CalDav_MuellkalDate1: “17.11.2016”

Now i want 1 item with the data "blaue Tonne -> 17.11.2016"
How can i do this?

BR Rene

Create a Rule that triggers on update to either of those two Items and postUpdate to a Third Item.

String CalDav_MuellMerged1 ...
rule "Update CalDav_MuellMerged1"
    Item CalDav_MuellkalName1 received update or
    Item CalDav_MuellkalDate1 received update
    CalDav_MuellMerged1.postUpdate(CalDav_MuellkalName1.state.toString + " -> " + CalDav_MuellkalDate1.state.toString)


too slow :grin:

But 1 small addition to what @rlkoshak said: If you want to convert the DateTime item to a specific format you can for example use

... + CalDav_MuellkalDate1.state.toString("HH:mm")

The function to put it into 1 field works, Thanks.
But i cannot get only the date(17.11.2016) from the item “CalDav_MuellkalDate1.state.toString”, i tried like CalDav_MuellkalDate1.state.toString(“dd.MM.yyyy”) but i dont work. I tried CalDav_MuellkalDate1.state.toString(“HH:mm”) too, but it dont work.
I get always these string:

“blaue Tonne -> 2016-11-17T00:00:00.000+0100”

Whats wrong with the rule?

BR Rene

Now it works, i found a solution:


Thanks for the help.

Ah, sorry. My mistake.
My post above was for Joda DateTime variable, not for a DateTime Item.

But good to hear you found a solution :wink: