Skip to main content
Question

Extract Time Stamp

  • March 29, 2017
  • 4 replies
  • 115 views

mbaer
Contributor
Forum|alt.badge.img+1

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

erik_jan
Contributor
Forum|alt.badge.img+26
  • 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+26
  • 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.

 


mbaer
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • March 30, 2017

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