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 / Get AM or PM from Date...
Power Apps
Unanswered

Get AM or PM from DateTime

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Is there a way to get the AM or PM from an entity DateTime field? 

 

I can get Date() Hour() Minute() separated ... but can't figure out how to get the AM/PM designation from the entity field. 

 

Other than something like this?

 

Right(DateTimeValue,2)

 

Categories:
  • dinusc Profile Picture
    Microsoft Employee on at

    Since you can get the Hour() value, would something like If(Hour() >11,"PM,"AM") work for you? Example:

    If(Hour(Now())>11,"PM","AM")
  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    Are you using CDS as data source? If so, by default in the Display Form, the DateTime field is already shown as AM/PM format:
    Capture.PNG

     

    You could create an auto-generated app to have a test. 

     

    If you mean that you want the AM/PM shows in Edit Form, you can edit the card (after unlocking it) and add an AM/PM option. Here are some properties that you'll need to updat. The new dropdown is called AM/PM "AmPmValue1":

    AmPmValue1.Items: ["AM", "PM"]
    AmPmValue1.Default: If(Hour(Parent.Default) < 12, "AM", "PM")
    HourValue1.Items: ["12","01","02","03","04","05","06","07","08","09","10","11"]
    HourValue1.Default: Text(If(Mod(Hour(Parent.Default), 12) = 0, 12, Mod(Hour(Parent.Default), 12)),"00")
    DataCard1.Update: DateValue1.SelectedDate + Time(If(AmPmValue1.Selected.Value = "PM", 12, 0) + Mod(Value(HourValue1.Selected.Value), 12), Value(MinuteValue1.Selected.Value), 0)

     

     

    See detailed solution here:

    https://powerusers.microsoft.com/t5/General-Discussion/DatePicker-AM-PM/td-p/42766

     

    Regards,

    Mona 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you!

     

    I'm using the CDS, but with a custom input to enter date/time so I had to go a different route, but I was able to set the Default based on the time.

     

    AMPMDropdown.Default = Right(Text(editIncidentTime),2)

    powerapps-incident-ampm.png

     

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I


    @v-monli-msft wrote:

    Hi @Anonymous,

     

    Are you using CDS as data source? If so, by default in the Display Form, the DateTime field is already shown as AM/PM format:
    Capture.PNG

     

    You could create an auto-generated app to have a test. 

     

    If you mean that you want the AM/PM shows in Edit Form, you can edit the card (after unlocking it) and add an AM/PM option. Here are some properties that you'll need to updat. The new dropdown is called AM/PM "AmPmValue1":

    AmPmValue1.Items: ["AM", "PM"]
    AmPmValue1.Default: If(Hour(Parent.Default) < 12, "AM", "PM")
    HourValue1.Items: ["12","01","02","03","04","05","06","07","08","09","10","11"]
    HourValue1.Default: Text(If(Mod(Hour(Parent.Default), 12) = 0, 12, Mod(Hour(Parent.Default), 12)),"00")
    DataCard1.Update: DateValue1.SelectedDate + Time(If(AmPmValue1.Selected.Value = "PM", 12, 0) + Mod(Value(HourValue1.Selected.Value), 12), Value(MinuteValue1.Selected.Value), 0)

     

     

    See detailed solution here:

    https://powerusers.microsoft.com/t5/General-Discussion/DatePicker-AM-PM/td-p/42766

     

    Regards,

    Mona 


     


    @v-monli-msft wrote:

    Hi @Anonymous,

     

    Are you using CDS as data source? If so, by default in the Display Form, the DateTime field is already shown as AM/PM format:
    Capture.PNG

     

    You could create an auto-generated app to have a test. 

     

    If you mean that you want the AM/PM shows in Edit Form, you can edit the card (after unlocking it) and add an AM/PM option. Here are some properties that you'll need to updat. The new dropdown is called AM/PM "AmPmValue1":

    AmPmValue1.Items: ["AM", "PM"]
    AmPmValue1.Default: If(Hour(Parent.Default) < 12, "AM", "PM")
    HourValue1.Items: ["12","01","02","03","04","05","06","07","08","09","10","11"]
    HourValue1.Default: Text(If(Mod(Hour(Parent.Default), 12) = 0, 12, Mod(Hour(Parent.Default), 12)),"00")
    DataCard1.Update: DateValue1.SelectedDate + Time(If(AmPmValue1.Selected.Value = "PM", 12, 0) + Mod(Value(HourValue1.Selected.Value), 12), Value(MinuteValue1.Selected.Value), 0)

     

     

    See detailed solution here:

    https://powerusers.microsoft.com/t5/General-Discussion/DatePicker-AM-PM/td-p/42766

     

    Regards,

    Mona 



    @v-monli-msft wrote:

    Hi @Anonymous,

     

    Are you using CDS as data source? If so, by default in the Display Form, the DateTime field is already shown as AM/PM format:
    Capture.PNG

     

    You could create an auto-generated app to have a test. 

     

    If you mean that you want the AM/PM shows in Edit Form, you can edit the card (after unlocking it) and add an AM/PM option. Here are some properties that you'll need to updat. The new dropdown is called AM/PM "AmPmValue1":

    AmPmValue1.Items: ["AM", "PM"]
    AmPmValue1.Default: If(Hour(Parent.Default) < 12, "AM", "PM")
    HourValue1.Items: ["12","01","02","03","04","05","06","07","08","09","10","11"]
    HourValue1.Default: Text(If(Mod(Hour(Parent.Default), 12) = 0, 12, Mod(Hour(Parent.Default), 12)),"00")
    DataCard1.Update: DateValue1.SelectedDate + Time(If(AmPmValue1.Selected.Value = "PM", 12, 0) + Mod(Value(HourValue1.Selected.Value), 12), Value(MinuteValue1.Selected.Value), 0)

     

     

    See detailed solution here:

    https://powerusers.microsoft.com/t5/General-Discussion/DatePicker-AM-PM/td-p/42766

     

    Regards,

    Mona 




    In this way, when we input 12 pm it turns the am pm value to Am.

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    this works for me:

     

     

    Spoiler (Highlight to read)
    DateValue1.DefaultDate: Parent.Default

    DateValue1.Format: DateTimeFormat.ShortDate

    AmPmValue1.Items: ["AM", "PM"]

    AmPmValue1.Default: If(Hour(Parent.Default) < 12, "AM", "PM")

    HourValue1.Items: ["12","1","2","3","4","5","6","7","8","9","10","11"]

    HourValue1.Default:
        If(
            Hour(Parent.Default) = 0, 12,
            Hour(Parent.Default) < 13, Hour(Parent.Default),
            Hour(Parent.Default) < 24, Hour(Parent.Default) - 12
        )

    MinuteValue1.Items: ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"]

    MinuteValue1.Default: If(Minute(Parent.Default)<10, "0" & Minute(Parent.Default), Minute(Parent.Default))

    DataCard1.Update:
        DateValue1.SelectedDate +
        Time(
            If(
                AmPmValue1.Selected.Value = "AM" && Value(HourValue1.Selected.Value) = 12,     00,
                AmPmValue1.Selected.Value = "AM" && Value(HourValue1.Selected.Value) <> 12,   Value(HourValue1.Selected.Value),
                AmPmValue1.Selected.Value = "PM" && Value(HourValue1.Selected.Value) = 12,      12,
                AmPmValue1.Selected.Value = "PM" && Value(HourValue1.Selected.Value) <> 12,    Value(HourValue1.Selected.Value) + 12
            ),
            Value(MinuteValue1.Selected.Value),
            00
    )
    DateValue1.DefaultDate: Parent.DefaultDateValue1.Format: DateTimeFormat.ShortDateAmPmValue1.Items: ["AM", "PM"]AmPmValue1.Default: If(Hour(Parent.Default) < 12, "AM", "PM")HourValue1.Items: ["12","1","2","3","4","5","6","7","8","9","10","11"]HourValue1.Default:    If(        Hour(Parent.Default) = 0, 12,        Hour(Parent.Default) < 13, Hour(Parent.Default),        Hour(Parent.Default) < 24, Hour(Parent.Default) - 12    )MinuteValue1.Items: ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"]MinuteValue1.Default: If(Minute(Parent.Default)<10, "0" & Minute(Parent.Default), Minute(Parent.Default))DataCard1.Update:    DateValue1.SelectedDate +    Time(        If(            AmPmValue1.Selected.Value = "AM" && Value(HourValue1.Selected.Value) = 12,     00,            AmPmValue1.Selected.Value = "AM" && Value(HourValue1.Selected.Value) <> 12,   Value(HourValue1.Selected.Value),            AmPmValue1.Selected.Value = "PM" && Value(HourValue1.Selected.Value) = 12,      12,            AmPmValue1.Selected.Value = "PM" && Value(HourValue1.Selected.Value) <> 12,    Value(HourValue1.Selected.Value) + 12        ),        Value(MinuteValue1.Selected.Value),        00)

     

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard