You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Russell Whitaker <ru...@gmail.com> on 2015/09/09 22:53:46 UTC

Getting yesterday's date, or getting date offsets in general?

I'm setting up a GetSFTP processor to run every morning to
download files expected in a regular location named based on the
previous day's date,
e.g. /logs/2015-09-08. I'm trying to set the GetSFTP processor "Remote path"
config setting with something like this:

/logs/${date:toDate('YESTERDAY'):format('yyyy-MM-dd')}

or

/logs/${now()-86400000:format('yyyy-MM-dd')

Both fail of course. In the second case, I'm trying a brute force
offset based on the
Nifi expression language guide, which says this for now():

"The now function returns the current date and time as the number of
milliseconds since Midnight GMT on January 1, 1970"

Not according to my testing, and also checking NowEvaluator.java, which actually
returns a DataQueryResult instance. As for the toDate('YESTERDAY')
attempt, there
seems to be no evaluator support for it, nor in
java.text.SimpleDateFormat which it
imports and uses. Anyone have suggestions for addressing this use case?

Thanks!
R

-- 
Russell Whitaker
http://twitter.com/OrthoNormalRuss
http://www.linkedin.com/pub/russell-whitaker/0/b86/329

Re: Getting yesterday's date, or getting date offsets in general?

Posted by Russell Whitaker <ru...@gmail.com>.
Michael, that worked perfectly! Thanks!

Russell

On Wed, Sep 9, 2015 at 3:15 PM, Michael Moser <mo...@gmail.com> wrote:
> Russell,
>
> Try this expression in your Remote Path:
>
> /logs/${now():toNumber():minus(86400000):format('yyyy-MM-dd')}
>
> -- Mike
>
> On Wed, Sep 9, 2015 at 4:53 PM, Russell Whitaker <russell.whitaker@gmail.com
>> wrote:
>
>> I'm setting up a GetSFTP processor to run every morning to
>> download files expected in a regular location named based on the
>> previous day's date,
>> e.g. /logs/2015-09-08. I'm trying to set the GetSFTP processor "Remote
>> path"
>> config setting with something like this:
>>
>> /logs/${date:toDate('YESTERDAY'):format('yyyy-MM-dd')}
>>
>> or
>>
>> /logs/${now()-86400000:format('yyyy-MM-dd')
>>
>> Both fail of course. In the second case, I'm trying a brute force
>> offset based on the
>> Nifi expression language guide, which says this for now():
>>
>> "The now function returns the current date and time as the number of
>> milliseconds since Midnight GMT on January 1, 1970"
>>
>> Not according to my testing, and also checking NowEvaluator.java, which
>> actually
>> returns a DataQueryResult instance. As for the toDate('YESTERDAY')
>> attempt, there
>> seems to be no evaluator support for it, nor in
>> java.text.SimpleDateFormat which it
>> imports and uses. Anyone have suggestions for addressing this use case?
>>
>> Thanks!
>> R
>>
>> --
>> Russell Whitaker
>> http://twitter.com/OrthoNormalRuss
>> http://www.linkedin.com/pub/russell-whitaker/0/b86/329
>>



-- 
Russell Whitaker
http://twitter.com/OrthoNormalRuss
http://www.linkedin.com/pub/russell-whitaker/0/b86/329

Re: Getting yesterday's date, or getting date offsets in general?

Posted by Michael Moser <mo...@gmail.com>.
Russell,

Try this expression in your Remote Path:

/logs/${now():toNumber():minus(86400000):format('yyyy-MM-dd')}

-- Mike

On Wed, Sep 9, 2015 at 4:53 PM, Russell Whitaker <russell.whitaker@gmail.com
> wrote:

> I'm setting up a GetSFTP processor to run every morning to
> download files expected in a regular location named based on the
> previous day's date,
> e.g. /logs/2015-09-08. I'm trying to set the GetSFTP processor "Remote
> path"
> config setting with something like this:
>
> /logs/${date:toDate('YESTERDAY'):format('yyyy-MM-dd')}
>
> or
>
> /logs/${now()-86400000:format('yyyy-MM-dd')
>
> Both fail of course. In the second case, I'm trying a brute force
> offset based on the
> Nifi expression language guide, which says this for now():
>
> "The now function returns the current date and time as the number of
> milliseconds since Midnight GMT on January 1, 1970"
>
> Not according to my testing, and also checking NowEvaluator.java, which
> actually
> returns a DataQueryResult instance. As for the toDate('YESTERDAY')
> attempt, there
> seems to be no evaluator support for it, nor in
> java.text.SimpleDateFormat which it
> imports and uses. Anyone have suggestions for addressing this use case?
>
> Thanks!
> R
>
> --
> Russell Whitaker
> http://twitter.com/OrthoNormalRuss
> http://www.linkedin.com/pub/russell-whitaker/0/b86/329
>