nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Payne <>
Subject Re: How can i compare hours in which data having with current datetime hours?
Date Mon, 23 Jan 2017 14:53:21 GMT

I think the RouteText processor will give you what you need. If you set the "Matching Strategy"
property to "Satisfies Expression,"
then it will allow you to use the Expression Language to evaluate each line of text in the
file. Each line of text is available using
the "line" variable. So, for example, you could create a Property named "older.than.72.hours"
with a value of something like:
${line:getDelineatedValues(2):toDate('MM.dd.yyyy HH:mm:ss'):toNumber():lt( ${now():minus(259200000)}

The now():minus(259200000) means subtract 259200000 milliseconds (72 hours) from the current

So this will look at each line in the text file, get the second delineated value (by default
it uses a comma as the delimiter), convert
it to a date/time using the format of <month>.<day of month>.<4 digit year>
<24-hour>:<minute>:<second>, and then convert
that to a number (in milliseconds since midnight Jan. 1, 1970). It then compares this value
to see if the value is less than the current
date/time minus 72 hours.

Each line of text that matches will be routed to 'older.than.72.hours'. Note, the outgoing
FlowFiles may contain several lines of text
each, though. It does not split the output into individual lines. You can do so if necessary
via SplitText.


On Jan 23, 2017, at 5:23 AM, prabhu Mahendran <<>>

My input contains dateTime with hours like below.,

1,23.01.2016 09:02:21,Mega,201
2,03.01.2016 10:02:23,Hema,202

Now i need to get 2nd Column ["02.01.2016 10:02:23"] and then compare it with current dateTime
with milliseconds.

After that if 2nd Column is in between past 72 hours and then insert into sql server.

For example.,

                 My Current DateTime is "04.01.2016 10:23:21"

                For 1st row.,

                                     1,23.01.2016 09:02:21,Mega,201

                                    =>Compare 23.01.2016 09:02:21 with 04.01.2016 10:23:21
[Current Time].It couldn't insert into SQL Server due to DateTime is not past 72 hrs when
it                                                  compared  with current dateTime.

                For 2 nd row,

                                    2,03.01.2016 10:02:23,Hema,202
                                   =>This Should be insert into SQL Server.Because it's
date is "03.01.2016" and it is past 72 hour data by compare it with current datetime.

How can i achieve my use case in Nifi Processors?

Please stop me if anything am doing wrong,


View raw message