Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

Power App - 12 Hour Formatting

Posted on by 14
I have a Leave Request Power App connected to a sharepoint list. I want the Power App to show the time option in 12 hour format instead of 24 hour. 
 
 
I added a drop-down for AM & PM option. Default is showing 
If(Hour(Parent.Default)<12,"AM","PM")
 
Hour Default drop down option is showing:
Text(If(Mod(Hour(Parent.Default),12)=0,12,Mod(Hour(Parent.Default),12)),"[$-en-US]00")
 
HOur Items Option is showing: 
["12","01","02","03","04","05","06","07","08","09","10","11"]
 
I have tried to updated the Date Started to reflect the AM & PM option.The Micorosoft List dates(both start & end) will show both dates as AM or PM.
 
This is the current setting for "Update" on my data card
If(Not IsBlank(DateValue2.SelectedDate), DateTime(Year(DateValue2.SelectedDate), Month(DateValue2.SelectedDate), Day(DateValue2.SelectedDate),
Value(HourValue2.Selected.Value), Value(MinuteValue2.Selected.Value), 0))
  • WarrenBelz Profile Picture
    WarrenBelz 143,532 on at
    Power App - 12 Hour Formatting
  • Suggested answer
    CU22111957-0 Profile Picture
    CU22111957-0 2 on at
    Power App - 12 Hour Formatting
    Just wanted to post this. Thanks @WarrenBlez for your post. It worked for me, but I found a bug where it doesn’t handle the special case for 12 AM correctly.
    If(
        !IsBlank(StartDateValue.SelectedDate),
        DateTime(
            Year(StartDateValue.SelectedDate),
            Month(StartDateValue.SelectedDate),
            Day(StartDateValue.SelectedDate),
            If(
                StartHourValue.Selected.Value = 12,
                If(StartAMPM.Selected.Value = "AM", 0, 12),
                Value(StartHourValue.Selected.Value) + If(StartAMPM.Selected.Value = "PM", 12, 0)
            ),
            Value(StartMinuteValue.Selected.Value),
            0
        )
    )
    

    This formula checks if the selected hour is 12 and adjusts accordingly:
    • If it’s 12 AM, it sets the hour to 0.
    • If it’s 12 PM, it keeps the hour as 12.
    • For other hours, it adds 12 if it’s PM.
     
  • DHall-1 Profile Picture
    DHall-1 14 on at
    Power App - 12 Hour Formatting
    That worked. Thank you so much
     

  • Suggested answer
    WarrenBelz Profile Picture
    WarrenBelz 143,532 on at
    Power App - 12 Hour Formatting
    Using your drop-down name, try this
    If(
       !IsBlank(DateValue2.SelectedDate), 
       DateTime(
          Year(DateValue2.SelectedDate), 
          Month(DateValue2.SelectedDate), 
          Day(DateValue2.SelectedDate),
          Value(HourValue2.Selected.Value) + 
          If(
             AMPMDropdown.Selected.Value = "PM",
             12
          ), 
          Value(MinuteValue2.Selected.Value), 
          0
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,532

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,050

Leaderboard