web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Split Text Time-To-Tim...
Power Apps
Answered

Split Text Time-To-Time Into Collection of Filtered Hours and Minutes

(0) ShareShare
ReportReport
Posted on by 473

I have a string that defines a configurable a range of Business Hours,

 

0930-1830

 


May I know how can I split the string above into a collection of hours and (conditional minutes) to populate in a combo box?

Hours:

 

["09","10","11","12","13","14","15","16","17","18"]

 

Minutes: 

 

["00","15","30","45"]

 

However, the minutes is conditional.
E.g. If Business Hours starts at 0930, if 09 hour is selected, minimum minutes is 30.

Thank you.
----------------------------
Edit:
I have split hours and minutes, for From and To values, from the string variable:

 

Set(
 BusinessHoursVal,
 First(
 ClearCollect(
 BusinessHoursCol,
 Filter(
 Configurations,
 "Business_Hours" in Key
 )
 )
 ).Value
);

 

 

Set (FromHoursVal, Left( BusinessHoursVal, 2 )); //09
Set (FromMinutesVal, Mid( BusinessHoursVal, 3,2 )); //30
Set (ToHoursVal, Mid( BusinessHoursVal, 6,2 )); //18
Set (ToMinutesVal, Right( BusinessHoursVal, 2 )); //30

 

Categories:
I have the same question (0)
  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at

    For hour drop down I would use 

    Sequence(Mid(hoursstring,6,2) -Left(hoursstring,2), Left(hoursstring,2))

    you might have to utilize text(left(),”##”) to keep the leading 0 if you require that. 

    for minutes Sequence( If(Hoursselected = Left(hoursstring,2),Mid(3,2),60),0)

     

    Ending would be like

    Sequence(If(endingselected =Mid(6,2),Mid(8,2),60),0)

     

    im doing this on my phone in bed so forgive any syntax but should get you on the right path. 

    basically taking sequence to populate using the left function to get the two left characters as hours and mid function at the 2nd hours position which should always be same characters to get them. And subtract the right from left to get how many to sequence. 

    then using same thing basically sequence 60 times from 0 unless the selected hour is equal the start / end and use that number from the string as how many to sequence. 

    hope this helps.   

  • ruihaolrh Profile Picture
    473 on at

    Hi @cwebb365 , thank you for the formulas.

    I set the Hours correctly, as follows:

     

    Sequence(Mid(BusinessHoursVal,6,2) -Left(BusinessHoursVal,2)+1, Left(BusinessHoursVal,2))

     

     

    For minutes, the values are populated if hour 10 is selected. But encounter no values in combobox if hour 9 is selected.

     

    Sequence( If(FromTimeHour_Ddl.Selected.Value = Value(Left(BusinessHoursVal,2)),Mid(3,2),60),0)


    I also noticed that the values can be in single digits, which I am intending to display all as double digits.

     

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at

    That Mid(3,2) should have the business hours in it. 

    Mid(

    BusinessHoursVal

    ,3,2)

     

  • ruihaolrh Profile Picture
    473 on at

    Hi @cwebb365 , appreciate your reply with the correction. I updated the variable into Mid(), but noticed 2 things.

    1. The Minute values populated are 1 to 29, instead of 30 to 59.
    (From 0930)

     

    Sequence( If(FromTimeHour_Ddl.Selected.Value = Value(Left("0930-1800",2)),Mid("0930-1800",3,2),60),0)

     


    2. There will be no values if the Starting Minutes in string is "00".
    e.g. (From 0900)

     

     

    Sequence( If(FromTimeHour_Ddl.Selected.Value = Value(Left("0900-1800",2)),Mid("0900-1800",3,2),60),0)

     

     

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at

    For the start minutes Add a 60 - before the If. And wrap the if in a Value().  This will get how many minutes to 60. Then replace the 0 at the end for the start position using the value() of the same Left() used inside the If that will start at the number of the open hours minutes.  

  • Verified answer
    cwebb365 Profile Picture
    3,294 Most Valuable Professional on at
    Sequence( If(FromTimeHour_Ddl.Selected.Value = Value(Left("0930-1800",2)),60 - Mid("0930-1800",3,2),60),Value(Left("0930-1800",2))

    Sorry at a computer finally. Should be able to add 60 - before the mid as shown to get difference from 60 minutes. So if it's 00 it'll be 60, is it's 30 will be 30 and so forth. starting position is also changed by putting the Left in it. You might need to adjust by a -1 / +1 or something if it looks off. 

     

    This should solve both those issues. I think you said you need double digits you should be able to wrap the sequence code in a Text(Sequence(code),"##") to return double digits for everything.  

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at

    Just saw your edit making those variables, you could use a With() statement to handle that as well, but anyway, here is simplified version. 

     

    Start Dropdown items. 

    Text(Sequence( If(FromTimeHour_Ddl.Selected.Value = Value(FormHoursVal),60-FromMinutesVal,60),FromMinutesVal),"##")

     

    End DropDown Minutes Items

    Text(Sequence(ToMinutesVal + 1,0),"##")

    Think the +1 is needed to account for 00's

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard