[GIS] How to convert date to an arbitrary format in FME Workbench

fme

My source dataset is DWG and destination is GDB. The source dataset has Date attributes as Char in DD-MM-YYYY. The corresponding destination attributes have to be of Date datatype, that too in M/D/YYYY format.

I tried DateFormatter transformer, with output date format string as FME Date (%D), I got the error as

The date 'FME Date (05/14/1981)' is not valid. Valid forms for a date type are YYYYMMDD, YYYYMMDDHHMMSS, or HHMMSS

For format string as %D, I got error as:

The date '05/14/1981' is not valid. Valid forms for a date type are YYYYMMDD, YYYYMMDDHHMMSS, or HHMMSS

For format string as %m"/"%e"/"%Y and %m/%e/%Y, again the above error message.

As from the error, I cannot perform the desired formation. Is there a transformer available in FME Workbench to perform desired format conversion? Or should I try something like using SubstringExtractor and then StringConcatenator? I need to read the documentation thoroughly to see if I can get it working.

Thanks

Best Answer

Try %Y%m%d, %Y%m%d%H%M%S or %H%M%S.

Update: There seems to be two issues that the DateFormatter is unable to deal with:

  1. Hyphens, and
  2. Days before months in numeric formats, such as 30/12/2011.

To work around both these issues I came up with the following: FME Workbench screenshot

The first two transformers just create a dummy test feature with a date attribute of 30-12-2011.

  • The AttributeSplitter creates a list out of the date by splitting it at the hyphens.
  • The AttributeExposer makes the list elements visible as individual attributes.
  • The StringConcatenator reorders the list elements and adds slashes, resulting in MM/DD/YYYY format.
  • The DateFormatter then converts back to YYYYMMDD, zero-padding the month/day where necessary.

The writer is a file geodatabase writer that writes a single row to a table. It runs and the output viewed in ArcCatalog is as expected: TEST_DATE is displayed as 12/30/2011.

Related Question