Populate a drop-down list box with dates excluding weekends

This InfoPath demo is the completed solution for a bonus recipe in InfoPath 2013 Cookbook in which a drop-down list box on an InfoPath 2013 form is populated with dates that exclude weekends.

In this bonus recipe you will learn how to populate a drop-down list box on an InfoPath 2013 form with dates that exclude weekends.

Get more solutions from InfoPath 2013 Cookbook which is available on Amazon.com
Watch the next InfoPath demo: Limit the amount of lines in a multi-line text box

InfoPath demo video transcript:

Here I'm in SharePoint 2013 where I've already published an InfoPath form template to this SharePoint form library. So if I click new document to add a new form, you'll see that as soon as the InfoPath form opens, it will display this drop-down list box control on it containing the current system date. Actually, if we look closely at the date, today is the 4th of August, which falls on a Sunday, but the drop-down list box is still displaying a Monday, so the 5th of August.

If I open the drop-down list box, you'll see that I'm displaying the day of the week in front of the dates and none of these names are either a Saturday or a Sunday, so basically the weekends are being filtered out of this drop-down list box. Just like in recipe 106 of InfoPath 2013 Cookbook, you can select a different date and move up in time like this, or you can select a day in the past and move back in time like this.

I'll save this form back to the form library, close it, and then I'll download it. And then I'll open the InfoPath form in Notepad and manually change the date to be a date in the past, and I'll make the date be a Saturday... the 20th of April was a Saturday. If we double-check here, you can see that April 20 was a Saturday.

So I'll save that date in the InfoPath form and then I'll upload the form back to the form library. And now when I open this form, we should see that the date is the Monday after the 20th, so that would be the 22nd of April being displayed in the drop-down list box. And that is the exact date that we see.

And then again you can select a different date and move up in time like this, or you can move back in time, or you can move to the current system date, which will be the Monday after the Sunday, so the 5th of August.


Related InfoPath Demo Videos:


Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners