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?
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?
As @nielsgerrits says, the DateTimeConverter transformer is the way to go. Its parameters would look something like this:
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.
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.
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