I’m currently extracting data from a table that gives me time format in a string format
I need to turn these values into a Double, converting the value into minutes. So, for example, the string “1 hr 5 mins” needs to be shown as 65.0. The String “9 mins 24 secs” needs to be shown as 9.4.
I’ve already extracted the data, have it in a datatable, and can access each cell but I’m unsure of how I can split the string up to do the math. Any help would be greatly appreciated!
Hi
The expression be like this inside the for each row loop
row(“yourcolumnname”) = IF(row(“yourcolumnname”).ToString.Contains(“hr”) AND row(“yourcolumnname”).ToString.Contains(“mins”),
Cint(System.Text.RegularExpressions.Regex.Match(row(“yourcolumnname”).ToString,”.\d\s(?=hr)”).ToString.Trim)*60+Cint(System.Text.RegularExpressions.Regex.Match(row(“yourcolumnname”).ToString,”.\d\s(?=min)”).ToString.Trim),
IF(row(“yourcolumnname”).ToString.Contains(“mins”) AND row(“yourcolumnname”).ToString.Contains(“sec”),
Cint(System.Text.RegularExpressions.Regex.Match(row(“yourcolumnname”).ToString,”.\d\s(?=min)”).ToString.Trim)+Cint(System.Text.RegularExpressions.Regex.Match(row(“yourcolumnname”).ToString,”.\d\s(?=sec)”).ToString.Trim),
IF(row(“yourcolumnname”).ToString.Contains(“mins” ), Cint(System.Text.RegularExpressions.Regex.Match(row(“yourcolumnname”).ToString,”.\d\s(?=min)”).ToString.Trim), Cint(System.Text.RegularExpressions.Regex.Match(row(“yourcolumnname”).ToString,”.\d\s(?=sec)”).ToString.Trim)))
I think your best bet is to use regex expressions, but im afraid im not very good with them, after that you can use TimeSpan class to retrieve it in minutes.