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 / Format Text to hh:mm
Power Apps
Unanswered

Format Text to hh:mm

(0) ShareShare
ReportReport
Posted on by 171

 

Hello all,

The code below will change my text input to the format hh:mm. This will format the inputs such as 800 to 8:00 or 1000 to 10:00. My problem is when I enter 8:00 it is changed to 8::00 or 10:00 to 10::00. How do I prevent the colons? Or how do I catch the colons?

 

If(
 Len(input.Text) > 2,
 UpdateContext(
 {
 locVarColon: 
 If(
 Len(input.Text) = 3,
 Left(input.Text, 1) & ":" & Right(input.Text, 2),
 Left(input.Text, Len(input.Text)-2) & ":" & Right(input.Text, 2)
 )
 }
 );
 Reset(input)
);

 

 

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

    Hi @alt88 ,

    I reproduce the scene in this way
    If you use the button to trigger the change of the input style, if you click repeatedly in the judgment, 10:::00 will appear

    vchengfenmsft_0-1678872699402.pngvchengfenmsft_1-1678872723049.png

    Please try:

    Button 's OnSelect:

    If(
    Len(input.Text) > 2&&Len(input.Text)<5,
    UpdateContext(
    {
    locVarColon: If(
    Len(input.Text) = 3,
    Left(
    input.Text,
    1
    ) & ":" & Right(
    input.Text,
    2
    ),
    Left(
    input.Text,
    Len(input.Text) - 2
    ) & ":" & Right(
    input.Text,
    2
    )
    )
    }
    ),
    Reset(input)
    );

     

    Best Regards

    Cheng Feng

  • alt88 Profile Picture
    171 on at

    More information for my case:
    The input field is in a gallery. Data from the collection is displayed in this input field. By patching on clicking an icon, I add a line to the collection, which causes another empty input field to appear in the gallery. Another time is recorded in this input field. This input field is used for formatting. This means that when I enter a new number, it is formatted from 800 to 8:00 (in the onChange). Your addition does not add another colon, but if I add another field and then add 900 there, the value from before is displayed, i.e. 8:00 instead of 9:00. This is the case for all other fields that I add. The full code I use in the onChange looks like this.

    Set(
     locVarColon,
     Blank()
    );
    
    If(
     Len(input.Text) > 2 && !(":" in input.Text),
     UpdateContext(
     {
     locVarColon: 
     If(
     Len(input.Text) = 3,
     Left(input.Text, 1) & ":" & Right(inpStartzeit.Text, 2),
     Left(input.Text, Len(input.Text)-2) & ":" & Right(input.Text, 2)
     )
     }
     );
     Reset(input)
    );
    
    
    
    Patch(
     colTime,
     LookUp(
     colTime,
     id = ThisItem.id
     ),
     {
     abc_starttime: If(
     !IsBlank(locVarColon),
     locVarColon,
     Self.Text
     )
     }
    );
    

    and the default is: ThisItem.abc_starttime

     

    and the icon to patch a new row: 

    Patch(colTime, Defaults(colTime), {abc_name:"Time", id:GUID(), abc_date: datDateWhite.SelectedDate});

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard