how to derive using todays date (now), yesterdays date with desired time stamp.
todays date is 09-13-2016 03:00:00 and derive yesterdays date 9-12-2016 11:59:59 always to in format of mm-dd-yyyy 11:59:00. always default timestamp to 11:59:00. we can do this in oracle using formatting the date but how can it be achieved in NIFI?
This EL statement takes now subtracts the remainder resulting from dividing now by 86400000 (number of milliseconds in 24 hours) and then subtracts an additional 43260000 (12 hours and 1 minute) from that result and finally formatting the output in the date format you are looking for.
I confirmed this EL statement by using it in an UpdateAttribute processor:
and if I look at the attributes on a FlowFile that was processed by the above, I see:
You can see that the attribute "yesterday" is set to exactly one day earlier from "current time" and 11:59:00.
There is the possibility that the time could differ slightly (ms) between when both now() functions are called in that expression language which could cause the result to push pack to 11:58:59. To avoid this you can simply reduce 43260000 by a few milliseconds (43259990) to ensure that does not happen so 11:59:00 is always returned.