I have developed a Leave Power App that connects to a Microsoft List. The timestamps entered are from staff in the Eastern and Central time zones. I want the times submitted through the Power App to be recorded exactly as they appear on the Microsoft List, without any timezone conversion.
I created the following patch for the "Submit" button, but I keep encountering an error that I cannot resolve. Any assistance would be greatly appreciated. I have attached an image of the error and a view of the app's build. Additionally, I have dropdowns for selecting the date and time.
With(
{
// START — build local start timestamp
_h1: Value(HourValue3.Selected.Value),
_m1: Value(MinuteValue3.Selected.Value),
_isPM1: Dropdown14.Selected = "PM",
_h1_24: If(_isPM1 && _h1 <> 12, _h1 + 12, If(!_isPM1 && _h1 = 12, 0, _h1)),
_startLocal:
Date(
Year(DateValue3.SelectedDate),
Month(DateValue3.SelectedDate),
Day(DateValue3.SelectedDate)
) + Time(_h1_24, _m1, 0),
_startUtc: DateAdd(_startLocal, -TimeZoneOffset(_startLocal), TimeUnit.Minutes),
// END — build local end timestamp
_h2: Value(HourValue2.Selected.Value),
_m2: Value(MinuteValue2.Selected.Value),
_isPM2: Dropdown13.Selected = "PM",
_h2_24: If(_isPM2 && _h2 <> 12, _h2 + 12, If(!_isPM2 && _h2 = 12, 0, _h2)),
_endLocal:
Date(
Year(DateValue2.SelectedDate),
Month(DateValue2.SelectedDate),
Day(DateValue2.SelectedDate)
) + Time(_h2_24, _m2, 0),
_endUtc: DateAdd(_endLocal, -TimeZoneOffset(_endLocal), TimeUnit.Minutes)
},
Patch(
'DFS Leave/Overtime Request',
Defaults('DFS Leave/Overtime Request'),
{
// Dates
'Date Started': _startUtc,
'Date Ended': _endUtc,
// Other fields
'Name': DataCardValue1.Text,
'Email Address': DataCardValue17_1.Text,
'Supervisor Email': DataCardValue17.Text,
'Comments': DataCardValue6.Text,
'Time Zone': DataCardValue2.Text,
'Leave/Overtime': Radio1.Selected.Value
}
)
)