Help! New to powerapps and just can't find the answer. I have a calculation for the minutes between start time field and end time field. The calculation works until the calculation crosses between am to pm. Below is my code. What am I doing wrong ?
DateDiff(
DateValue2.SelectedDate + Time(Value(HourValue2.Selected.Value), Value(MinuteValue2.Selected.Value), Value(AmPmValue2.Selected.Value), 0),
DateValue3.SelectedDate + Time(Value(HourValue3.Selected.Value), Value(MinuteValue3.Selected.Value), Value(AmPmValue3.Selected.Value), 0),
Minutes)
Solved! Go to Solution.
Hi @Leapster ,
I have never used the am/pm and I can't find any reference to it working, however there is one error needing correction for it to have any chance - the am/pm is text, so you do not need Value in front of it.
DateDiff(
DateValue2.SelectedDate +
Time(
Value(HourValue2.Selected.Value),
Value(MinuteValue2.Selected.Value),
AmPmValue2.Selected.Value, 0
),
DateValue3.SelectedDate +
Time(
Value(HourValue3.Selected.Value),
Value(MinuteValue3.Selected.Value),
AmPmValue3.Selected.Value, 0),
Minutes
)
If this does not work, try
DateDiff(
DateValue2.SelectedDate +
Time(
If(
AmPmValue2.Selected.Value = "PM",
Value(HourValue2.Selected.Value) + 12,
Value(HourValue2.Selected.Value)
),
Value(MinuteValue2.Selected.Value), 0
)
,
DateValue3.SelectedDate +
Time(
If(
AmPmValue3.Selected.Value = "PM",
Value(HourValue2.Selected.Value) + 12,
Value(HourValue3.Selected.Value)
),
Value(MinuteValue3.Selected.Value), 0
),
Minutes
)
Please click Accept as solution 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 Thumbs Up.
Hi @Leapster ,
I have never used the am/pm and I can't find any reference to it working, however there is one error needing correction for it to have any chance - the am/pm is text, so you do not need Value in front of it.
DateDiff(
DateValue2.SelectedDate +
Time(
Value(HourValue2.Selected.Value),
Value(MinuteValue2.Selected.Value),
AmPmValue2.Selected.Value, 0
),
DateValue3.SelectedDate +
Time(
Value(HourValue3.Selected.Value),
Value(MinuteValue3.Selected.Value),
AmPmValue3.Selected.Value, 0),
Minutes
)
If this does not work, try
DateDiff(
DateValue2.SelectedDate +
Time(
If(
AmPmValue2.Selected.Value = "PM",
Value(HourValue2.Selected.Value) + 12,
Value(HourValue2.Selected.Value)
),
Value(MinuteValue2.Selected.Value), 0
)
,
DateValue3.SelectedDate +
Time(
If(
AmPmValue3.Selected.Value = "PM",
Value(HourValue2.Selected.Value) + 12,
Value(HourValue3.Selected.Value)
),
Value(MinuteValue3.Selected.Value), 0
),
Minutes
)
Please click Accept as solution 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 Thumbs Up.
The second code is working like a charm. Thank you!
User | Count |
---|---|
180 | |
114 | |
88 | |
44 | |
42 |
User | Count |
---|---|
226 | |
113 | |
112 | |
69 | |
67 |