cancel
Showing results for 
Search instead for 
Did you mean: 

Convert String to Time

SOLVED
Highlighted
poles1c
Meteor

Hi,

 

I would like to the covert a string into the desired time format below: 

 

String: 165208

 

Desired format: 16:52:08

 

How would I go about doing this? 

 

Thanks!

 

Courtney

  • Preparation
Alteryx Certified Partner
Alteryx Certified Partner

Hi @poles1c,

 

If you are using version 11, you can use the date/time tool and use the 'custom' format.  The custom config would be:

hhmmss

Capture.PNG

That is pretty easy (given that your input is a STRING).

 

For a regular expression, I would do something like:

regex_replace([Field1],"(\d\d)(\d\d)(\d\d)",'$1:$2:$3')

if the incoming data doesn't have 6 characters (e.g. 95822), both will have issues.  If you don't have leading zeros, you will need to :

PadLeft([Field1],"0",6)

before your time conversion.

 

Does this help to solve your challenge?

 

Cheers,

Mark

 

 

 

ACE & Alteryx Certified Partner
Chaos reigns within. Repent, reflect and reboot. Order shall return.
poles1c
Meteor

Thanks!