DateFormatter

From fmepedia

DateFormatter is a Workbench Transformer.

Table of contents


Description

The DateFormatter takes an attribute containing a date in a format recognised by the transformer and converts it to a different format specified by the user.



Acceptable Source Date structures

Note the words "in a format recognized by the transformer" in the above sentence. The user doesn't specify the format of the source dates, a source date entering the DateFormatter MUST be in a format already known to the transformer; for example mm/dd/yyyy is acceptable, but dd/mm/yyyy won't work.


The help system in Workbench (http://www.safe.com/support/online-documentation/Workbench/transformers/dateformatter.htm) will provide you with the list of acceptable source formats for dates. The standard FME date format is yyyymmdd.



Relative Dates

The DateFormatter is capable of using relative dates as an input string, for example it can convert "next thursday" to "12-Jul-2007" or "three years ago" to "4-Jul-2004", based on today being 4-Jul-2007



Example 1

The attached workspace shows an example use of the DateFormatter transformer.

In this example two dates are created. One is reformatted, the other is the wrong structure to be reformatted.


Workspace Screenshot



Example 2

The attached workspace shows an example use of the DateFormatter transformer in relative mode.

In this example several relative dates are created, for example "tomorrow", "thursday next (http://en.wikipedia.org/wiki/Thursday_Next)", "3 years". The DateFormatter turns these relative dates into actual dates; for example if today is 4th July 2007 then "3 years" becomes 4th July 2010.


Workspace Screenshots


Above: The workspace as a whole is very simple.



Above: The AttributeCreator simply sets a date to "Next Thursday"...



Above: ...which the DateFormatter interprets as 12-Jul-2007 (which is indeed next Thursday - or was at the time this screenshot was taken).

Attached Files
filesizedate
DateFormatter Example.jpg88.8 kB11/11/08
DateFormatter Example.zip70.8 kB11/11/08
DateFormatter Example2.jpg80.1 kB11/11/08
DateFormatter Example2.zip65.4 kB11/11/08
DateFormatter Example2a.jpg22.7 kB11/11/08
DateFormatter Example2b.jpg8.2 kB11/11/08
User Comments Add a new comment