So I have a string variable that contains the amount of time that something took in the HH:MM format
I would like to seperate the hours and minutes into 2 seperate strings.
output: str1 = HH ; str2 = MM
How would I go about doing that?
So I have a string variable that contains the amount of time that something took in the HH:MM format
I would like to seperate the hours and minutes into 2 seperate strings.
output: str1 = HH ; str2 = MM
How would I go about doing that?
Date.ParseExact(“11:22”,“hh:mm”,System.Globalization.CultureInfo.InvariantCulture).Hour.ToString
Date.ParseExact(“11:22”,“hh:mm”,System.Globalization.CultureInfo.InvariantCulture).Minute.ToString
You also can
Hi,
Hope the following expressions helps you.
str1 = yourString.Split(":"c)(0)
str2 = yourString.Split(":"c)(1)
If your string contains except “HH:MM”, you need to extract “HH:MM” in advance as the following.
yourString = System.Text.RegularExpressions.Regex.Match(yourString,"\d{1,2}:\d{1,2}").Value
THen
str1 = yourString.Split(":"c)(0)
str2 = yourString.Split(":"c)(1)
Regards,