Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

I want to route flowfiles in nifi on comparison of a field value in flowfile with a constant date value.

avatar
Rising Star

Hi All, I want to route flowfiles in nifi on comparison of a field value in flowfile with a constant date value. eg i have a lastupdatedate field in my flowfile, i want to route all flowfiles to matched if lastupdatedate (format is '2017-03-12 06:07:12:01') is greater than '2017-07-31'. i am using routeonattribute processor. i formatted lastupdatefield as : ${d_last_updt:toDate('yyyy-MM-dd'):format('yyyyMMdd')} and then compared this value with the constant value (converting it to same format), but it seems the functions are not routing the flowfiles. please suggest where i am going wrong? Thanks in advance!!!!

3 REPLIES 3

avatar
Rising Star

@sri chaturvedi Please try converting both the variables to String datatype before comparison. Sample: ${d_last_updt:toDate('yyyy-MM-dd'):format('yyyyMMdd'):toString():gt(constant value:toString())}

Hope this helps

avatar
Rising Star

Thanks Ramasamy..i will try this.

avatar
Master Guru
@sri chaturvedi

if you are having d_last_updt attribute value as 2017-03-12 06:07:12:01 then in Route On Attribute processor add new property as

${d_last_updt:toDate('yyyy-MM-dd'):format('yyyyMMdd'):gt('20170731')} //todate extracts year month date from your lastupdatedate attribute and formats as yyyyMMdd then give your value in gt function.

This property checks all d_last_updt attribute value if the value is greater than 20170731 if attribute value satisfies the condition then it routes to property name relation , if not it routes to unmatched relation.

Route on Attribute processor Configs:-

43409-routeonattribute.png