# InfoPath Date Picker Control

Learn how to use InfoPath date picker and InfoPath date and time picker controls to perform date and time calculations.

## InfoPath 2003

### Use rules and formulas

#### Auto-formatting a time field in InfoPath when it loses the focus

Use rules, conditions, the concat() function, and the substring() function in InfoPath to convert the way a time field is displayed from hhmm to hh:mm when the field loses the focus.

#### Calculating a person's age given a date of birth using rules and formulas in InfoPath

Use rules, conditions, the today() function, the number() function, and the substring() function in InfoPath to calculate a person's age from his/her date of birth.

#### Calculating time differences in InfoPath without custom code

Use rules in InfoPath to calculate the difference between start and end times, and sum the time differences to get a grand total amount of hours.

#### Date and time basics in Microsoft Office InfoPath

Understand how Microsoft Office InfoPath uses dates to be able to do your own date manipulations and calculations within InfoPath.

#### Filtering a list in InfoPath on the current month and day period

Use rules and filter conditions in InfoPath to filter a list containing dates first on the current month and then on a specific period between a minimum and maximum day number.

### Write code

#### Calculating date and time differences in InfoPath using VBScript

Use VBScript in InfoPath to calculate the difference between start and end dates and times, and sum the time differences to get a grand total amount of hours.

#### Calculating date differences in InfoPath using VBScript code

Use VBScript code to calculate the difference between two date pickers in InfoPath.

#### Calculating time differences in InfoPath using custom JScript code

Use JScript code in InfoPath to calculate the difference between start and end times, and sum the time differences to get a grand total amount of hours.

#### Calculating work days between two date pickers in InfoPath using VBScript

Use the DateDiff and Weekday functions in VBScript to perform date difference calculations in InfoPath that produce the amount of work days between two dates.

#### Switching between day sections in InfoPath using xdExtensions and JScript

Use JScript to determine the day of the week (Monday through Sunday) based on a specified date chosen from a Date Picker, and use the result to conditionally show/hide sections on an InfoPath form.

## Date Pickers in InfoPath 2007

### Use rules and formulas

#### Auto-populate a repeating table in InfoPath with sequential dates

Learn how you can use a function and formulas in InfoPath 2007 to populate rows in a repeating table with sequential dates by entering one date and having the rest of dates automatically calculated and displayed.

#### Calculate the difference between two date picker controls in InfoPath using rules and formulas - no code!

Use rules, conditions, and the number(), floor(), and substring() functions in formulas to calculate the difference between two date picker controls in InfoPath.

#### Calculating date differences in InfoPath using SharePoint Excel Services

Use an Excel workbook published to Excel Services on a Microsoft Office SharePoint Server 2007 to calculate the difference between two dates in InfoPath without writing a single line of code.

#### Create a day of the week InfoPath form using rules and formulas

Use a formula to calculate the number for the day of the week (Monday through Sunday) based on a date specified in a Date Picker control, and conditional formatting on sections to show/hide the weekday sections on an InfoPath form.

#### Filter a SharePoint list in a repeating table in InfoPath on a date range

Use conditional formatting on a repeating table in InfoPath to filter a SharePoint list on a date range using two date picker controls.

#### Forcing users to select a particular day of the week from a date picker in InfoPath using rules and formulas

Use data validation, rules, and the number(), floor(), and substring() functions to derive and check the day of the week when a date is selected from a date picker control in InfoPath.

#### How to check whether a start date falls before an end date in InfoPath

This article shows you how to use data validation rules in InfoPath to compare two dates and check whether one date falls before another.

#### How to extract the month name from a date picker in InfoPath

Learn how to use a secondary data source, rules, filters, and InfoPath functions to extract the month name from the secondary data source based on the date that is displayed in a date picker control.

#### Selecting the minimum date in an InfoPath repeating table using formulas (no code)

Learn how you can use a formula (no code) in InfoPath to find and highlight the rows in a repeating table that contain the date that falls before all other dates in one of the repeating table's columns.

### Write code

#### Calculating date differences in InfoPath 2007 browser forms using C# code

Write C# code which uses the Site property of the XMLEventArgs object and the TimeSpan object in the Changed event of the date fields to calculate the difference between the dates in each row of a repeating table.

## Date and Time Pickers in InfoPath 2010

### Use rules and formulas

#### Calculate month difference in InfoPath 2010 using rules

Learn how you can use the number and substring functions, rules, conditions, and formulas in InfoPath 2010 to calculate the difference in months between two date picker controls.

#### Calculate work days excluding holidays in InfoPath 2010 using SharePoint 2010 and Excel Services

Learn how you can leverage Excel 2010, Excel Services in SharePoint 2010, and the new REST Web Service data connection in InfoPath 2010 to calculate the difference between two dates in InfoPath 2010 by getting back the amount of work days excluding holidays.

#### InfoPath 2010 date picker default value

Learn how you can set the default value for an InfoPath 2010 date picker or InfoPath 2010 date and time picker.

#### InfoPath 2010 date and time picker control basics

Learn how to add a Date and Time Picker control to an InfoPath 2010 form template and then set the value of the Date and Time Picker control using rules or code.

#### InfoPath 2010 date picker with only future dates allowed

Learn how you can use InfoPath data validation rules to allow only future dates to be selected from an InfoPath date picker and InfoPath 2010 date and time picker.

#### Not able to format time in InfoPath 2010

Learn what a few workarounds are for the issue of not being able to format a time text box in InfoPath 2010.