Skip to main content
Solved

Can you remove the decimal point from time attributes?

  • September 10, 2018
  • 4 replies
  • 194 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>
View original
Did this help you find an answer to your question?

4 replies

takashi
Evangelist
  • 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+39
  • Influencer
  • 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
  • September 11, 2018
takashi wrote:

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

 

 


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

 

 


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