How to retrieve a year about an Attribute

Hello all, I have an attribute called Retired_Date and the type is Date and time. I want to retrieve another attribute called Start_Date from one year before Retired_Date to Retired_Date. The XPath is [StartDate>$Devices/RetiredDate - '[%YearLength%]' and StartDate<$Devices/RetiredDate] But it’s error: mismatched input ‘-’ expecting BRACKET_CLOSE. So how to retrieve this one year? Thanks in advance.  
1 answers

You want a list of everyone that will retire within a year from any point in time, or within a year from today? Within a year from today then first create a variable OneYearFromNow and set it to addYears(‘[%CurrentDateTime%]’,1) and compare Retired_Date to that one. But I guess you need the other one.

Your problem is the ‘-’ because you can not do calculations with dates in an xpath-restriction. So do get this, which will give you a list of object :


Loop over that list in your microflow and check on the other restriction there.

Mind you, ‘[%YearLength%]‘ is nothing more than the number 365. Putting you off by one day in leapyears. Better is to use year-from-dateTime, add 1 and parseDatetime.

This is bound to take time, so if the entity you are retrieving from has a lot of objects, and you need it fast, use OQL.