In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!

Alteryx Designer Desktop Discussions

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

Adding 0 to single digit timestamp

viv_acious
6 - Meteoroid

Hi All,

 

I really need some advice! Have been trying to figure this out for ages...

 

I have a column (yyyy-mm-dd hh:mm:ss) however, the hour field is a single-digit if the hour is below 10.

For example, "2015-11-30 3:17:04

 

How do I use regex to make it into "2015-11-30 03:17:04"

 

Any advice appreciated!

 

Thanks,

Viv

2 REPLIES 2
JordanB
Alteryx Alumni (Retired)

Hi @viv_acious

 

I have attached an example workflow which does the following:

 

(.*) = Group everything up to a space - 1st marked group

\s = space in between date and time

(\d{1}\:)$ = Group everything which has 1 digit before a : - 2nd marked group (This means all those with two digits do not get a zero)

(.*) = Picks up everything else in the string

 

Replace text adds back in the first marked group with a space, then adds a zero and then second marked group

 

Best,

 

Jordan Barker

Solutions Consultant

danrh
13 - Pulsar

You could also use the DateTime tool:

 

image.png

 

Hope it helps!

Labels
Top Solution Authors