Skip to main content
Question

User parameter - Date Time Now as Default value

  • October 25, 2018
  • 1 reply
  • 723 views

philippeb
Enthusiast
Forum|alt.badge.img+22

Hi!

I'm trying to create in FME Desktop a published parameter that contains the date time now as a default value.

After publishing my script on FME Server, when I go on the web page calling that parameter, I'm not getting a value. I get the function string.

I tried to choose a Date type in my user parameter, but I only get a calendar.

Any idea how to get the current date time in a user parameter?

Thanks!

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.

1 reply

david_r
Celebrity
  • 8394 replies
  • October 25, 2018

I don't think that's possible, although it would be very handy!

I've solved this exact same case by having one published, optional parameter of type String (let's call it DATE_GAME), and one private Python scripted parameter (let's call it DATE_GAME_FOR_REAL here).

The definition of DATE_GAME_FOR_REAL could look like this:

from datetime import datetime
date_game = FME_MacroValues.get('DATE_GAME', None)
if date_game:
    return date_game
else:
    return datetime.now().strftime('%Y%m%d%H%M%S')

This function returns the value of DATE_GAME if the user typed anything into the field. If DATE_GAME is empty, it defaults to the current timestamp.

Then in my workspace I never reference DATE_GAME, only DATE_GAME_FOR_REAL.