ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
GELÖST

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

Mildman
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 ANTWORTEN 4
ed_hayter
Pulsar

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
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
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
Pulsar

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

 

Spoiler
image.png
Beschriftungen
Top-Lösungs-Autoren