Prabhu,

Using epoch time might end up being a simpler comparison.   If the
converted date is less than
1483254000 (midnight of first day of current month), it is the previous
month (for my timezone).Thanks,
Lee


On Thu, Jan 26, 2017 at 10:42 PM, prabhu Mahendran <prabhuu161...@gmail.com>
wrote:

> Hi Andy,
>
> i have already tried with your alternative solution.
> "UpdateAttribute to add a new attribute with the previous month value,
> and then RouteOnAttribute to determine if the flowfile should be inserted
> "
>
> i have used below expression language in RouteOnAttribute,
>
>
> *${literal('Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'):getDelimitedField(${csv.1:toDate('dd.MM.yyyy
> hh:mm:ss'):format('MM')}):equals(${literal('Dec,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov'):getDelimitedField(${now():toDate('
> Z MM dd HH:mm:ss.SSS yyyy'):format('MM'):toNumber()})})}*
>
>
> it could be failed in below data.,
>
> *23.12.2015,Andy,21*
> *23.12.2017,Present,32*
>
>
> My data may contains some past years and future years
>
> It matches with my expression it also inserted.
>
> I need to check month with year in data.
>
> How can i check it?
>
>
> On Fri, Jan 27, 2017 at 10:52 AM, Andy LoPresto <alopre...@apache.org>
> wrote:
>
>> Prabhu,
>>
>> I answered this question with an ExecuteScript example which will do what
>> you are looking for on Stack Overflow [1].
>>
>> [1] http://stackoverflow.com/a/41887397/70465
>>
>> Andy LoPresto
>> alopre...@apache.org
>> *alopresto.apa...@gmail.com <alopresto.apa...@gmail.com>*
>> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
>>
>> On Jan 26, 2017, at 8:40 PM, prabhu Mahendran <prabhuu161...@gmail.com>
>> wrote:
>>
>> Hi All,
>>
>> I have data in which i need to compare month of data if it is previous
>> month then it should be insert otherwise not.
>>
>> *Example:*
>>
>> *23.12.2016 12:02:23,Koji,24*
>> 22.01.2016 01:21:22,Mahi,24
>>
>> Now i need to get first column of data (23.12.2016 12:02:23) and then get
>> month (12) on it.
>>
>> Compared that with before of current month like.,
>>
>>
>> *If current month is 'JAN_2017',then get before of 'JAN_2017' it should
>> be 'Dec_2016'*
>> For First row,
>>
>> *compare that 'Dec_2016' with month of data 'Dec_2016' *[23.12.2016]*.*
>>
>> It matched then insert into database.
>>
>> if it not matched then ignore it.
>>
>> is it possible in nifi?
>>
>> Many thanks,
>> prabhu
>>
>>
>>
>>
>>
>

Reply via email to