Setting the DefaultDate in a Power App Date Picker with a Smarter Tomorrow

This is a little one, but sort of cool. I’m building a Power App which takes orders for shipment between stores. The person filling out the form can request a delivery date, but we want to give them a decent default. (It would be great if we could set minimum or maximum date in a date picker, but we can’t.)

Generally, something requested today can be delivered tomorrow, so we want a tomorrow which is smart about weekends, regardless what day of the week it is.

I came up with this little formula to set the DefaultDate for the form’s Requested Delivery Date date picker:

If(
     Weekday(Now()) = 6, // Friday
     Today() + 4,
     Weekday(Now()) = 7, // Saturday
     Today() + 3,
     Weekday(Now()) = 1, // Sunday
     Today() + 2,
     Today() + 1
 ) 

Like in Excel, the Weekday function returns the day’s number, where

ResultMeaning
1Sunday
2Monday
3Tuesday
4Wednesday
5Thursday
6Friday
7Saturday

The net-net of the formula is:

If

  Today is Friday, the following Tuesday

Else

  Today is Saturday, the following Tuesday

Else

  Today is Sunday, the following Tuesday

Else

  Tomorrow

This won’t stop people from picking a bad date, but it will put them in the right place to start.

We will probably make this fancier to handle things like times after noon, but this is a good starting point for a smarter date picker.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.