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)
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")
Hi @BrandonMcG,
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:
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
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)
I
@v-monli-msft wrote:Hi @BrandonMcG,
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:
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 @BrandonMcG,
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:
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 @BrandonMcG,
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:
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.
User | Count |
---|---|
136 | |
134 | |
78 | |
72 | |
69 |
User | Count |
---|---|
222 | |
136 | |
78 | |
60 | |
54 |