How to Update Related Date Picker Controls in a Canvas PowerApp

Colin Maitland, 04 September 2019

In this article, I demonstrate how to configure two related date picker controls in a Canvas PowerApp so that Date To is updated to Date From, and Date From is updated to Date To, if the User selects a Date From date that is greater than Date To or a Date To date that is less than Date From.

The existing configuration ensures that the Date From, Date To and Days controls default to the desired values, and Days automatically calculates. That configuration is described in a previous article.

The following image shows the app’s Edit Form open for adding a new Leave Request.

Here, the User has changed Date From to a date that is greater than Date To:

Here, the User has changed Date To to a date that is less than Date From:

The following changes can be made to the existing configuration of the OnChange events for these date picker controls to resolve this issue.

The OnChange event of the Date From date picker control can be updated as highlighted in the following image. Here, varDateTo is updated to match varDateFrom if it is less than varDateFrom. As a result, the selected date in the Date To date picker control is also updated. There is no need to use Reset to update the Date To control.

The OnChange event of the Date To date picker control can be updated as shown in the following image. Here, varDateFrom is updated to match varDateTo if it is greater than varDateTo. As a result, the selected date in the Date From date picker control is also updated. There is no need to use Reset to update the Date From control.

Resultingly, the following images show how the Date To or the Date From are automatically updated if the User selects a greater Date From date or a lesser Date To date.

Here, the User selected a greater Date From date and so Date To has been automatically updated to match Date From.

Here, the User selected a lesser Date To date and so Date From has been automatically updated to match Date To.

In conclusion, the configuration of the Date From, Date To and Days controls demonstrated in this and my previous article show how easy it is to configure a working solution for such functionality.