cancel
Showing results for 
Search instead for 
Did you mean: 
Announcement | Looking to grow your skills and business impact? Join us in Anaheim June 4-7 for Inspire 2018! Sign up by year-end for BIG DISCOUNTS. Register now.

Convert String to Time

SOLVED
Highlighted
poles1c
Asteroid

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

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

 

 

 


===> https://community.alteryx.com/t5/Engine-Works-Blog/SANTALYTICS-2017/ba-p/93770 <===
Chaos reigns within. Repent, reflect and reboot. Order shall return.
poles1c
Asteroid

Thanks!