Skip to main content
Solved

Can you remove the decimal point from time attributes?

  • September 10, 2018
  • 4 replies
  • 243 views

Morning,

I have a list of attributes that I've created with DateTimeConverter in the format %H:%M:%S. However, there is a decimal point at the end with a couple of numbers.

Eg. 08:13:56.236

Does anyone know a way to get rid of everything after and including the decimal point? I've tried attribute splitter and rounder and also @int() and @floor(). But nothing seems to be working

Thanks in advance :)

Best answer by takashi

Hi @hayleynicol, a possible way is to use the StringReplacer with these parameters.

  • Mode: Replace Regular Expression
  • Text To Replace \\.\\d*$
  • Replacement Text: <empty>
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

takashi
Celebrity
  • 7843 replies
  • Best Answer
  • September 11, 2018

Hi @hayleynicol, a possible way is to use the StringReplacer with these parameters.

  • Mode: Replace Regular Expression
  • Text To Replace \\.\\d*$
  • Replacement Text: <empty>

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3429 replies
  • September 11, 2018

If you actually want to round, rather than just drop everything after the decimal then if you convert to an FME time then round, then convert back to the format you require that will work


  • Author
  • 1 reply
  • September 11, 2018

Hi @hayleynicol, a possible way is to use the StringReplacer with these parameters.

  • Mode: Replace Regular Expression
  • Text To Replace \\.\\d*$
  • Replacement Text: <empty>
Awesome, that worked. Was struggling with the 'Text to Replace' field. Thank you

 

 


  • 4 replies
  • September 15, 2018

Hi @hayleynicol,

an alternative to @takashi's solution might be using SubstringExtractor as follows:

Maybe it is a bit easier, because it doesn't require regular expressions. Sometimes they might be a bit tricky;) Please note, that this approach preserves the original attribute and generates a new one with desired result.

"aa" is the name of the attribute you wish to perform operation on (yeah, I wasn't very creative here;)).