Free Trial

Alteryx Designer Desktop Discussions

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

Convert text string from 2 Days 12 Hours 5 Minutes to mins

Mildman
7 - Meteor

I have an app that give a duration in the format Days Hours Minutes and I need to calculate the number of mins from the string.

 

Examples of the string;

2 Days 12 Hours 5 Minutes

12 Days 1 Hour 1 Minute

1 Hour 35 Minutes

1 Day 1 Minute 

35 Minutes

 

4 REPLIES 4
ed_hayter
12 - Quasar

image.png

 

Went with regex parse here - find the numbers before "space minute" (case insensitive in case minute is not capitalized and minute in order to catch both minute and minutes

 

EDIT: If there are duplicate spaces between or no spaces at all the expression can be adjusted to have a * following the \s.

Mildman
7 - Meteor

I need to work out the mins, i.e.

 

2 Days 12 Hours 5 Minutes = 2 *24*60 + 12*60 + 5 = 3605 mins

 

 

abassett
6 - Meteoroid

Assuming you'll always have minutes, this regex should work

 

(\d*(?=\sd))?\D*?(\d*(?=\sh))?\D*?(\d*(?=\sm))\D*?

 

\D here being non-digit character

 

and ?= is using the lookahead to keep things in order to the first group is digits followed by a d for days etc.

ed_hayter
12 - Quasar

 Sorry about the misunderstanding - this is an ugly way of doing this:

 

Spoiler
image.png
Labels
Top Solution Authors