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 / How do I sort a galler...
Power Apps
Answered

How do I sort a gallery by Time (hours and minutes)?

(0) ShareShare
ReportReport
Posted on by 437 Super User 2024 Season 1

How do I sort this gallery so that the 6:30 rows comes after the 6:00 AM row and the 1:30 PM row comes after the 1:00 PM row?

 

Tried: SortByColumns(colTimeSlots,"BeginningTime",SortOrder.Ascending)

Beginning Time is set as TimeValue: TimeValue(TSBeginningTimeInput.Text)

 

BrianM_0-1700511865218.png

Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Brian-M ,

     

    I've made a test and the formula worked well on myside,

    1\I assume there is a collection:

    ClearCollect(
     colTimeSlots,
     {BeginningTime:TimeValue("6:30AM")},
     {BeginningTime:TimeValue("6:00AM")},
     {BeginningTime:TimeValue("1:30PM")},
     {BeginningTime:TimeValue("1:00PM")}
    ) 

    2\Sort the collection

    vbofengmsft_0-1700530062651.png

    SortByColumns(colTimeSlots,"BeginningTime",SortOrder.Ascending)

     

    Best Regards,

    Bof

     

  • Verified answer
    Brian-M Profile Picture
    437 Super User 2024 Season 1 on at

    Turns out my data source (SQL) used the format datetime2 so it wasn't resorting newly add times as the format is:

    2023-11-21 07:00.  I changed the data source to varchar and used "TimeValue" in Powerapps and it's working properly now.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard