Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Convert String to Time

poles1c
8 - 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

5 REPLIES 5
MarqueeCrew
20 - Arcturus
20 - Arcturus

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

 

 

 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
poles1c
8 - Asteroid

Thanks!

Nilesh_Pal
5 - Atom

Hi, I am a newbie in Alteryx, I have converted the string to 6 digits, but not able to convert it into date formate using Regex, the number is in this way: 093500. 

 

Thanks

Nilesh_Pal
5 - Atom

Sorry but I got the solution, I was doing it using date-time parse, but this time I tried using the formula tool. and this worked.

 

Thanks a lot, this was helpful

sophabraham95
5 - Atom

please share the formula you have used. thank you.

Labels