DateTimes and FME
Date and time attributes (commonly known as DateTimes) are handled in FME using a variety of transformers and functions. This page covers a number of frequently asked questions about these transformers, plus some sections of general information.
FME DateTime Transformers
Q) What transformers are available for handling datetimes in FME?
There are three main transformers for handling datetimes in FME:
- DateTimeConverter: Converts a set of input DateTime attributes from one format to another.
- DateTimeCalculator: Performs arithmetic operations on dates, times, and intervals.
- DateTimeStamper: Adds a timestamp to a feature as a new attribute.
These transformers have existed since about FME 2017. Out of approximately 500 transformers, the DateTimeConverter is (at the time of writing) the 77th most-used FME transformer. The DateTimeStamper is #131 and DateTimeCalculator #134.
The DateTimeConverter is used for converting the format of datetime attributes. Common uses are to make datetimes more human-readable, or to convert human-readable datetimes into a format more suitable for storage and analysis. For example, converting %B %e %Y %l:%M%p (for example December 30 2018 4:32am) to %Y%m%d%H%M%S (20181230043200) makes the date less readable, but capable of being sorted numerically.
The DateTimeCalculator is used for carrying out arithmetic calculations. Common uses are to add or subtract a certain amount of time from a datetime, or to find the interval between two datetimes. For example, I can calculate that the elapsed time between 3-October-2015 and 25-July-2019 is P3Y9M22D (3 years, 9 months and 22 days) or simply 1,391 days.
The DateTimeStamper is used to create a datetime attribute whose value records the time the transformer was used. Common uses are to record when a feature was processed. For example, this sentence was written at 20190725090341.5325659 (25-July-2019 at 9:03:41am).
FME Hub DateTime Transformers
A number of datetime-related transformers are also available on the FME Hub.
Be aware that some transformers on the FME Hub often replicate functionality that already exists in FME, and some are made obsolete by newer FME functionality. Having said that, some useful hub transformers might be:
- DateValidator: Determines if a date string is valid as a Gregorian calendar date
- RelativeDateCalculator: Returns relative dates such as "Last Thursday" or "Next Day of the Week"
- TimeZoneExtractor: Returns time zone information based on the location of incoming features
- WorkingDaysCalculator: Returns the interval between two dates as the number of working days.
Transformers posted by either "Safe Software Official" or "Safe Software Lab" should be high enough quality to be used in production. Transformers posted by "Safe Sandbox" or by other FME users are not of a guaranteed quality.
Documentation and Other Sources of Information
Q) What documentation is available for datetime handling in FME?
FME documentation can be found on our community web site.
- Specific transformer documentation is found here: DateTimeConverter, DateTimeCalculator, DateTimeStamper
- Information on datetime terminology, the FME standard date format, and the ISO 8601 interval format, can be found in the transformers documentation.
- Information on the FME DateTime functions and the argument flags used by them can also be found in the transformers documentation.
A number of FME blog posts on datetimes can be found at safe.com/blog, including:
- FME 2017.1: Yet Another Awesome Datetime Update
- FME 2017: Dates, DateTimes, and their use in Temporal Calculations
- The Top Ten FME Tips of All Time!
You can also find more information by searching this site and the questions asked in the forums panel, or ask a new question.
DateTime Ideas
Q) What future enhancements might be made to datetime handling in FME?
A number of suggestions on the Ideas page deal with DateTimes. Here are some you might find interesting:
- DateTimeRounder: A suggestion for a DateTimeRounder transformer
- User Parameters: A suggestion to allow user parameters access to DateTime functions
- Stardate Support: A suggestion to add support for Stardates in FME!
Feel free to visit these - and other - ideas, and upvote them to show your support.
Other Frequently Asked Questions
Q) Does FME support time zone abbreviations such as ACT, CST, PDT, and so on?
A) No. At this time only UTC offsets (for example -08:00) are supported.
Q) Can I test dates in the Tester transformer or sort by date in the Sorter transformer?
A) Yes. The FME standard datetime format can easily be sorted numerically. The Tester transformer has a special mode for DateTime tests.
Q) Can FME handle fractional seconds?
A) Yes, FME datetime transformers all handle fractional seconds.
Comments
0 comments
Please sign in to leave a comment.