Skip to main content

How to Save a Date and Time to a SharePoint List with Patch in Power Apps

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

To save a date to SharePoint with Patch, pass a Date to a date-only column and a DateTime to a date-and-time column, as values, not text. SharePoint then shows exactly what the person chose, as long as the site's time zone is the one they work in. A night shift saved this way showed as 24/10/2026 22:00 to 25/10/2026 06:00.

The example is the Overtime Timesheet app. Its Log overtime screen saves each shift to the OvertimeEntries list: the day it started, its real start and finish, the month as text, and its hours.

Prerequisites​

The Columns and Their Values​

SharePoint columnTypeValue from the app
WorkDateDate onlyThe date picker's SelectedDate, a Date
StartTimeDate and timeShiftStart(...), a DateTime
EndTimeDate and timeShiftEnd(...), a DateTime, on the next day for a night shift
WorkMonthSingle line of textText(date, "yyyy-mm"), such as 2026-10
HoursNumber, 2 decimal placesMinutes worked divided by 60, rounded to 2 places
StatusChoice{Value: "Pending"}

Step 1: Work Out the Start and Finish Once​

With names the start and finish, so the Patch and the hours use exactly the same moments (How to Use the With Function in Power Apps):

Part of btnSaveLO → OnSelect
With(
{
Starts: ShiftStart(dpWorkDateLO.SelectedDate, cmbStartLO.Selected.Value),
Ends: ShiftEnd(dpWorkDateLO.SelectedDate, cmbStartLO.Selected.Value, cmbEndLO.Selected.Value)
},
...
)

ShiftStart and ShiftEnd are the app's own functions (How to Create a User-Defined Function in Power Apps).

Step 2: Patch the Values​

Inside the With:

Part of btnSaveLO → OnSelect
Patch(
OvertimeEntries,
Defaults(OvertimeEntries),
{
WorkDate: dpWorkDateLO.SelectedDate,
StartTime: Starts,
EndTime: Ends,
BreakMinutes: numBreakLO.Value,
Hours: Round((DateDiff(Starts, Ends, TimeUnit.Minutes) - numBreakLO.Value) / 60, 2),
DepartmentId: cmbDepartmentLO.Selected.ID,
Department: cmbDepartmentLO.Selected.Department,
Reason: Trim(txtReasonLO.Text),
EmployeeName: MyProfile.displayName,
EmployeeEmail: MyEmail,
Status: {Value: "Pending"},
WorkMonth: Text(dpWorkDateLO.SelectedDate, "yyyy-mm")
}
)

The column's default in SharePoint is Pending, but Defaults doesn't bring it into the app: in Studio, Defaults(OvertimeEntries).Status.Value showed Blank, while Defaults(OvertimeEntries).BreakMinutes showed its default, 0. Microsoft's Defaults function page warns that data sources vary in how much default information they provide. So the Patch sets Status itself.

The Patch sits inside IfError, so a failed save tells the person why (How to Stop a Button Being Selected Twice While It Saves in Power Apps has the whole formula). In the formula bar:

The start of the OnSelect property of btnSaveLO in the expanded formula bar: UpdateContext setting locIsSaving to true, With computing Starts and Ends, then IfError around Patch to OvertimeEntries with Defaults and the record with WorkDate, StartTime, EndTime, BreakMinutes, Hours, DepartmentId, Department, Reason, EmployeeName, EmployeeEmail, Status and WorkMonth

Step 3: Check the List in SharePoint​

I saved two shifts from the app in Preview: the night of 24 October from 22:00 to 06:00 with a 60-minute break, and 6 November from 17:00 to 20:30. In the list's All Items view, they appear with the times as entered, the night shift's EndTime on the 25th, and Status Pending:

The All Items view of the OvertimeEntries list with two earlier entries and, outlined in red, the two new ones: WorkDate 24/10/2026, StartTime 24/10/2026 22:00, EndTime 25/10/2026 06:00, BreakMinutes 60, Hours 8.00, Emergency Department, and WorkDate 06/11/2026, StartTime 06/11/2026 17:00, EndTime 06/11/2026 20:30, BreakMinutes 0, Hours 3.50, Radiology, both by Admin User with Status Pending

Their WorkMonth values were 2026-10 and 2026-11.

Why the Times Match​

Canvas apps hold every date and time in UTC and show it in the time zone of the browser or device (data types). SharePoint shows date and time columns in the site's time zone. The app ran in a browser on London time and the site is on London time, so both show the same clock times, including across the night the clocks went back.

If people work in a different time zone from the site's, SharePoint shows their times shifted by the difference. Set the site's time zone to the one people work in.

Common Mistakes​

MistakeWhat happensDo this instead
Saving the finish on the start date for a night shiftThe finish is before the start, which the list's validation rule doesn't allowBuild the finish with ShiftEnd, on the next day when it's earlier
Relying on Defaults for a Choice column's defaultThe value can be blank in the appSet the column in the Patch
Converting times to UTC before savingThe saved times are shiftedSave the DateTime values as they are
A site in another time zone from its usersSharePoint shows the times shiftedSet the site's time zone where people work

Troubleshooting​

SymptomLikely causeFix
The times in SharePoint differ from the appThe site's time zone isn't the user'sCheck the site's Regional settings and the device's time zone
A date-only value shows a day out for some peopleTime zone adjustment of a dateMicrosoft's date and time troubleshooting guide covers it

FAQ​

Do I need to convert to UTC before saving?​

No. The app saved the times as they were, and SharePoint showed them unchanged. Converting first would move them: How to Convert Local Time to UTC in Power Apps with TimeZoneOffset.

Why store the month as text when the date is there?​

2026-10 is the same for every day in October and sorts in order, so finding or totalling a month's entries is a simple equality check on one indexed column.

Conclusion​

Pass a Date to a date-only column and a DateTime to a date-and-time column, set every value your app depends on in the Patch, and keep the site's time zone where people work. SharePoint then shows exactly the shift that was entered.

Additional Resources​