Skip to main content
Question

Add hours to date with attributecreator

  • October 27, 2016
  • 2 replies
  • 233 views

Hi,

I have a fairly basic script, a reader, an attribute creator to create new attributes, and a writer.

I want the attribute creator to calculate a date column by adding 8 hours to a value from an existing date column.

I am an FME newbie and would love some suggestions.

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.

2 replies

takashi
Celebrity
  • October 27, 2016

Hi @okgirl, a possible way with regular transformers is:

  1. DateFormatter: Format the date value in the %s format - the elapsed seconds since the epoch.
  2. Add 28800 seconds (= 8 hours x 3600 sec) to the value with the ExpressionEvaluator (or AttributeCreator or AttributeManager).
  3. DateFormatter_2: Re-format the value in the original date format.

See the help on the DateFormatter transformer to learn more about the Date Format Symbols.

Alternatively, the DateTimeCalculator from the FME Hub might also be available.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • October 28, 2016

[clock format [expr [clock scan now] +28800]]

in case u do wish to do it in a AttributeCreator

if needed u can add format strings like in DateFormatter using -format {%d-%m-%Y}

check tcl site for usage.