Default to Monday in the current week in InfoPath 2010

Watch this InfoPath demo of how you can create a codeless InfoPath form template with a date picker control that always displays a date that corresponds to the Monday in the current week no matter which day is selected from the date picker control.

Often times when creating a timesheet solution in InfoPath, you may want the timesheet form to automatically open and display the date for a particular weekday (generally Sunday or Monday, depending on which day of the week you consider to be the first day of the week) in the current week.

The current week is generally determined by the current date, which in InfoPath can be easily retrieved by using either the now() or the today() function in a formula.

Automatically switching to the date that pertains to either a Monday or a Sunday in the current week is a little bit more complex to achieve, but still doable without writing a single line of code.

The InfoPath video below demonstrates functionality where the date belonging to a Monday in the current week is automatically selected and shown in a date picker control when the InfoPath form opens. In addition, whenever a user manually selects a date from the date picker control and that date does not belong to the Monday in the selected week, the date for the Monday in that week is automatically set as the default date in the date picker control.

This way the form automatically selects the Monday in the current week if the user has not manually selected a date in a particular week, or the form forces the date to fall on a Monday no matter which date the user has selected in the date picker control.


Related InfoPath Articles:


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.