Skip to main content

I have a date field that contains both a date and time string. I want to extract the time string and put it in another field. I am pretty sure that a regex is what I need but can not get it to work.

Example: 4/4/2016 4:22:39 PM

Have a look at the DateFormatter transformer.

That allows to extract part of a date time.


Or even the AttributeSplitter transformer (split on a space and the first in the list is the date, the second the time and the third PM/AM).


Hi @mbaer

do you use FME 2016 or FME 2017?

As @erik_jan suggested, in FME 2016, the best option would be to use AttributeSplitter or DateFormatter.

In FME 2017, we have added new datetime functions (available through Text Editor e.g. in AttributeCreator) and are working on new transformers (e.g. DateTimeFormatter that will eventually replace DateFormatter).

These are some of the possible solutions using FME 2017 functions:

  • @DateTimeCast(@DateTimeParse(@Value(_datetime),%m/%d/%Y %I:%M:%S %p),time)
  • @DateTimeFormat(@DateTimeParse(@Value(_datetime),%m/%d/%Y %I:%M:%S %p),%H:%M:%S)
  • @DateTimeFormat(@DateTimeParse(@Value(_datetime),%m/%d/%Y %I:%M:%S %p),%I:%M:%S %p)

I am attaching demo workspace.

 


Thank you both. All of the above works. I am on 2017 so @LenaAtSafe worked best.


Reply