2

I have a string field with values such as 04.07.21 and I am trying to write to GDB but it's not working because date format is expected and string is provided.

How can I convert these values (04.07.21) to date format in FME?

1
  • 1
    Which version are you using - there has been changes in DateTime transformer(s) over the the past versions.
    – Mapperz
    Commented Jul 5, 2021 at 14:52

3 Answers 3

3

As @nielsgerrits says, the DateTimeConverter transformer is the way to go. Its parameters would look something like this:

enter image description here

The input format is set to:

%d.%m.%y2099

Why that? Well, firstly I'm assuming that it is 4th July and not 7th April (so %d.%m, not %m.%d) but secondly, the year is only a two-digit year. The lower-case %y format works for 1900-1999 only, so we have to give "a greatest year" to consider (see the Quick Reference info in the transformer dialog).

That will return the value:

20210704

That date is in an FME structure. Do we now have to convert it to a Geodatabase datetime structure? No. The Geodatabase writer will do that automatically when it writes the data.

Coincidentally, there is a webinar on datetimes in FME later this week. See this page for more details. It may help you to learn some of the capabilities of these transformers and functions.

1
  • 1
    thanks a lot, I never understood "%y####" but now I do
    – gisgis
    Commented Jul 6, 2021 at 21:13
2

One way to do this is to use the DateFormatter/DateTimeConverter transformer. You need to convert to yyyymmdd or yyyymmddhhmmss to write to the date / datetime field in a File Geodatabase.

3
  • can you explain how transformer parameters should look like ?
    – gisgis
    Commented Jul 4, 2021 at 9:35
  • I am looking solution at Date/Time Functions --> @DateTimeParse()...
    – gisgis
    Commented Jul 4, 2021 at 10:44
  • Just see the documentation, nothing difficult? From %d.%m.%y to %y%m%d. Commented Jul 4, 2021 at 13:04
1

Year 2023, you can do this:

Format date into one with FME (part 1) Regex filter

https://transparentgov.net/cleargov1/1193/format-date-into-one-with-fme-part-1-regex-filter

Format date into one with FME (part 2) FME attribute creator

https://transparentgov.net/cleargov1/1194/format-date-into-one-with-fme-part-2-fme-attribute-creator

Format date into one with FME (part 3) FME Date Time converter

https://transparentgov.net/cleargov1/1195/format-date-into-one-with-fme-part-3-fme-date-time-converter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.