Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.
Free Trial

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
Alteryx

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