Skip to main content
Question

Extract Time Stamp


Forum|alt.badge.img

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

4 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • March 29, 2017

Have a look at the DateFormatter transformer.

That allows to extract part of a date time.


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • March 29, 2017

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).


Forum|alt.badge.img

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.

 


Forum|alt.badge.img
  • Author
  • March 30, 2017

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings