Skip to main content
Solved

Create a published parameter with date

  • July 23, 2020
  • 2 replies
  • 199 views

geo-x
Supporter
Forum|alt.badge.img+6

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

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
Supporter
Forum|alt.badge.img+6
  • Author
  • Supporter
  • July 24, 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.

It's perfect !

Thanks @david_r !