Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nifi - how to add days to the date

Could somebody tell me how I can add x number of days to a date attribute that is in the format ("yyyy-MM-dd") in Nifi.

like image 844
John Avatar asked Aug 06 '18 16:08

John


1 Answers

Use toDate function to convert into unixtime then use plus function with milliseconds and finally use format function to get your desired format

Adding 1 day:

${date:toDate("yyyy-MM-dd"):toNumber():plus(86400000):format("yyyy-MM-dd")}

Example:

i'm having date attribute to the flowfile with value as 2018-01-10 and want's to add 1 day to the date attribute value.

Milliseconds for 1 day(24hr) is 86400000 so in the below expression i'm adding one day to the date attribute value.

Add new attribute in update attribute processor as

add_day and value as

${date:toDate("yyyy-MM-dd"):toNumber():plus(86400000):format("yyyy-MM-dd")}

enter image description here enter image description here

like image 167
notNull Avatar answered Oct 23 '22 19:10

notNull