In this article, we’ll explore the different ways of updating a Date field with PowerApps with Patch() method.
Current date
We use the Now() method. This will return the current date and time
Patch(
Books,
bookSelected,
{
WithdrawalDate:Now()
}
)
In 3 months’ time
The DateAdd method adds a unit of time to a given date. This method takes 3 parameters:
- Start date: Today in our example
- The unit: this number can be negative
- Unit type: from milliseconds to quarters to years
Patch(
Books,
bookSelected,
{
WithdrawalDate:DateAdd(Now(),3,TimeUnit.Months)
}
)
From a specific date
We use the Date() function, which requires 3 digits in the following order: year, day and month..
Patch(
Books,
bookSelected,
{
WithdrawalDate:Date(2030,11,7)
}
)
From a specific date and time
With Date() & Time()
Patch(
Books,
bookSelected,
{
WithdrawalDate:Date(2030,11,7) + Time(16,45,0)
}
)
With DateTime(), a method that combines the previous two into a single one
Patch(
Books,
bookSelected,
{
WithdrawalDate:DateTime(2030, 9, 19, 12, 45, 0)
}
)
With a DatePicker
We add a DatePicker Control named inDate. We call SelectedDate property to get the date selected by user
Patch(
Books,
bookSelected,
{
WithdrawalDate:inDate.SelectedDate
}
)
With a DatePicker and a Custom TimePicker (home made)
PowerApps provides a DatePicker, but it doesn’t include hours. So we’re going to build one.
1. Add a first ComboBox to manage time display
Name : inHour
Items : ForAll(Sequence(12), Text(Value,"00"))
2. Add a second ComboBox to manage minutes display
Name : inMinute
Items : ForAll(Sequence(59), Text(Value,"00"))
4. The result :

3. Now, the patch to support our DateTimePicker
Patch(
Books,
bookSelected,
{
WithdrawalDate:
inDate.SelectedDate
+ Time(inHour.Selected.Value, inMinute.Selected.Value, 00)
}
)