Skip to main content
Solved

Create a published parameter with date


geo-x
Contributor
Forum|alt.badge.img+5
  • Contributor

Dear FME community.

I've to use the dynamoDB connector with a partition key like a specific date (for example : today - 5 days).

For that I only can using a published parameter :

But in this case I don't have access to the date function :

Do you know how can I do that ?

For information, I've FME Server.

Thank you for your help.

Best answer by david_r

If you need today's date minus 5 days, you can use a private scripted Python parameter:

0684Q00000ArLFLQA3.png

import datetime
today = datetime.datetime.now()
five_days_ago = today - datetime.timedelta(days=5)
return five_days_ago.strftime('%Y-%m-%dT%H:%M:%S%Ez')

To avoid considering the time of day, replace the last line with:

return five_days_ago.strftime('%Y-%m-%dT00:00:00+00')

You can then reference $(FIVE_DAYS_AGO) in the FeatureReader / reader.

View original
Did this help you find an answer to your question?

2 replies

david_r
Celebrity
  • Best Answer
  • July 23, 2020

If you need today's date minus 5 days, you can use a private scripted Python parameter:

0684Q00000ArLFLQA3.png

import datetime
today = datetime.datetime.now()
five_days_ago = today - datetime.timedelta(days=5)
return five_days_ago.strftime('%Y-%m-%dT%H:%M:%S%Ez')

To avoid considering the time of day, replace the last line with:

return five_days_ago.strftime('%Y-%m-%dT00:00:00+00')

You can then reference $(FIVE_DAYS_AGO) in the FeatureReader / reader.


geo-x
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 24, 2020
david_r wrote:

If you need today's date minus 5 days, you can use a private scripted Python parameter:

0684Q00000ArLFLQA3.png

import datetime
today = datetime.datetime.now()
five_days_ago = today - datetime.timedelta(days=5)
return five_days_ago.strftime('%Y-%m-%dT%H:%M:%S%Ez')

To avoid considering the time of day, replace the last line with:

return five_days_ago.strftime('%Y-%m-%dT00:00:00+00')

You can then reference $(FIVE_DAYS_AGO) in the FeatureReader / reader.

It's perfect !

Thanks @david_r !


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings