Site icon @WonderLaura – Laura Rogers

PowerApps: Specify Date Ranges with the Modern Date Picker Control

One of the most exciting recent updates to PowerApps is the introduction of the modern date picker control, which includes new properties for StartDate and EndDate. This feature has been highly anticipated by the community, and it opens up a world of possibilities for enhancing user experience, and improving app functionality, and improving data accuracy.

The Importance of Date Ranges

Date pickers are a fundamental component in many applications, allowing users to select dates for various purposes such as scheduling, booking, and data entry. However, one common challenge has been the inability to restrict the selectable date range within the date picker. This limitation often led to user frustration and increased the likelihood of errors, as users could inadvertently select dates outside the desired range.

The new StartDate and EndDate properties in the modern date picker control address this issue by allowing app creators to specify a certain date range within which dates can be selected. This enhancement not only improves the user experience but also ensures data accuracy and consistency. Here is an example of a trip start and trip end date, where the trip end can only be selected as a date after the trip starts.

Date Picker: Exploring the StartDate and EndDate Properties

The StartDate and EndDate properties are straightforward to use and can be configured directly within the PowerApps interface. Here’s a closer look at how these properties work and how you can leverage them in your applications. These can be dynamic as well, referencing other controls.

Practical Applications

The ability to specify date ranges using the StartDate and EndDate properties opens up numerous practical applications. Here are a few examples of how you can use this feature to enhance your PowerApps solutions:

Implementing the Date Range Properties on the Date Picker

Implementing the StartDate and EndDate properties in your PowerApps application is a simple process. Here’s a step-by-step guide to get you started:

  1. Enable modern controls: In the app’s settings, on the Updates tab, turn Modern controls and themes ON.
  2. Add the Modern Date Picker Control: First, add the modern date picker control to your app. You can find this control in the PowerApps control gallery.
  3. Set the StartDate Property: Select the date picker control and navigate to the properties pane. In the StartDate property field, enter the desired start date. You can use a static date or a dynamic expression based on your app’s requirements.
  4. Set the EndDate Property: Similarly, (and optionally) set the EndDate property by entering the desired end date. Again, you can use a static date or a dynamic expression.
  5. Test Your App: Once you’ve configured the StartDate and EndDate properties, test your app to ensure that the date picker behaves as expected. Preview your app and try selecting dates within and outside the specified range to verify that the constraints are working correctly.

In this example, when someone selects a trip start, I don’t want them to select a date in the past, so I use the Today() function in the StartDate property:

Today is November 18th, so when the date picker is used, you can’t select any past dates:

In another example, when selecting the end date of a trip, you shouldn’t be able to select an end date before the start date that was selected in the start date picker.

If I wanted to restrict the duration of the requested trip to never be longer than one month, I could set the EndDate property of the trip end control to be dtePickTripStart.SelectedDate + 30

Conclusion

The introduction of the StartDate and EndDate properties in the PowerApps modern date picker control is a game-changer for app creators. This long-awaited feature provides greater control over date selection, enhances user experience, and ensures data accuracy. Whether you’re building event scheduling apps, booking systems, or any other kind of data entry forms, these properties offer a simple yet powerful way to improve your applications.

As you explore the possibilities of the new date picker control, consider how you can leverage the StartDate and EndDate properties to meet your specific needs.

For more detailed information, you can refer to the official documentation Modern date picker control in Power Apps

Happy app building!

Exit mobile version