Format a date, time, or number

Note   Some of the options described in this article apply only when you select English (United States) in the Locale list in the Date Format, Time Format, or Date and Time Format dialog boxes.

In Microsoft Office InfoPath, you can add data formatting to text box, expression box, and date picker controls on your form template to specify how dates, times, and numbers are displayed when users enter them into forms that are based on your form template.

In this article

An overview of data formatting

Compatibility considerations

Specify a date or time format

Specify the number of decimal places

Change how negative numbers are displayed

Add or remove percent formatting for a number

Add or remove a digit grouping symbol in a number

Add or remove a currency symbol

An overview of data formatting

You can use data formatting to specify how data is displayed when users enter data into text box, expression box, or date picker controls. You cannot use data formatting with other types of controls. For example, by adding data formatting to a control, you can help ensure that:

  • Dates that users enter into a date picker control have a format of dd/mm/yy, such as 14/03/07.

  • Times that users enter into a text box control have a format of 00:00:00, such as 09:46:55.

When you apply data formatting to a control, you can choose from a list of predefined formats, which differ depending on whether you are working with text box, expression box, or date picker controls. Data formatting is supported only for certain data types for these controls.

For example, if you add a text box control to your form template, you can choose from several different data types for that control, including text, whole number, decimal, date, time, and date and time. However, if you want to specify data formatting for that text box control, you can choose among only the whole number, decimal, date, time, and date and time formats, because those are the only data types for a text box control that support data formatting.

Data types, associated data formats, and the controls that support them

The following table lists the data types in InfoPath that support data formatting, the data format options for those data types, and the controls that support them.

Data types

Available data formats

Supported in these controls

Whole Number

  • None

  • Number

  • Currency

  • Text box

  • Expression box

Decimal

  • None

  • Number

  • Percentage

  • Currency

  • Text box

  • Expression box

Date

  • None

  • 3/14/2007*

  • Wednesday, March 14, 2007*

  • March, 2007*

  • Wednesday, March 14, 2007

  • March 14, 2007

  • Wednesday, 14 March, 2007

  • 14 March, 2007

  • 3/14/2007

  • 3/14/07

  • 03/14/07

  • 03/14/2007

  • 07/03/14

  • 2007-03-14

  • 14-Mar-07

  • March, 2007

  • Text box

  • Expression box

  • Date picker

Time

  • None

  • 9:46:55 AM*

  • 9:46 AM*

  • 9:46:55 AM

  • 09:46:55 AM

  • 9:46:55

  • 09:46:55

  • 9:46 AM

  • 09:46 AM

  • 9:46

  • 09:46

  • Text box

  • Expression box

  • Date picker

Date and Time

When you apply the Date and Time data type to a control, you can set the same data formats that you would set for the Date format and Time format separately. For example, you might set the Date format as March 14, 2007 and the Time format as 9:46.

  • Text box

  • Expression box

  • Date picker

Notes   

  • Data formats that have an asterisk will be updated to reflect the current format specified by the user's system settings.

  • If you select a locale other than English (United States), some date formats will be unavailable when your users fill out forms by using a Web browser. For example, the date format 14-mars-01 is not supported in the French (Belgium) locale.

Top of Page

Compatibility considerations

When you design a browser-compatible form template, some data formatting options are unavailable.

Top of Page

Specify a date or time format

Although you can specify data formatting for several data types, you can specify how dates and times are displayed only for date picker controls, text box controls, or expression box controls that have a date, time, or date and time data type.

Note   When you design a form template in InfoPath, you can choose a specific compatibility mode to design a browser-compatible form template. When a browser-compatible form template is published to a server running InfoPath Forms Services, and then browser-enabled, forms based on the form template can be viewed in a Web browser. Browser-compatible form templates do not support the display of the date and time in the same control. To display the date and time in two separate controls, refer to the procedure "Display the date and time in separate controls" at the end of this procedure.

  1. Double-click the date picker, text box, or expression box control whose data you want to format.

  2. In the Control Properties dialog box, do one of the following:

    • If you are working with a text box control or a date picker control, click the Data tab.

    • If you are working with an expression box control, click the General tab.

  3. Do one of the following:

    • For a text box control or a date picker control, ensure that the Data type list displays the appropriate data type, and then click Format.

    • For an expression box control, ensure that the Format as list displays the appropriate data type, and then click Format.

  4. In the Data type Format dialog box, do one of the following:

    • To format the control to show the date only, select the display style that you want in the Display the date like this list.

    • To format the control to show the time only, select the display style that you want in the Display the time like this list.

    • To format the control to show both the date and time, select the display style that you want for the date in the Display the date like this list, and then select the display style that you want for the time in the Display the time like this list.

      Note   Display styles that have an asterisk will be updated to reflect the current format specified by the user's system settings.

  5. To change the locale date and time settings, select the country or region that you want in the Locale list.

Browser-compatible form templates do not support the display of the date and time in the same control. Use the following procedure to display the date and time in separate controls:

Display the date and time in separate controls

Before you begin, make sure that your form template contains two controls, and that both controls are bound to the same field in the data source.

  1. Double-click the date picker, text box, or expression box control that you want to use to display the date.

  2. In the Control Properties dialog box, do one of the following:

    • If you are working with a text box control or a date picker control, click the Data tab.

    • If you are working with an expression box control, click the General tab.

  3. Ensure that the Data type list displays the Date and Time data type, and then click Format.

  4. In the Display the date like this list in the Date and Time Format dialog box, click the display style that you want.

  5. In the Display the time like this list, click (Do not display time).

  6. Click OK twice.

  7. Double-click the date picker, text box, or expression box control in your form template that you want to use to display the time.

  8. In the Control Properties dialog box, do one of the following:

    • If you are working with a text box control or a date picker control, click the Data tab.

    • If you are working with an expression box control, click the General tab.

  9. Ensure that the Data type list displays the Date and Time data type, and then click Format.

  10. In the Display the date like this list in the Date and Time Format dialog box, click (Do not display date).

  11. In the Display the time like this list, click the display style that you want.

  12. To change the locale date and time settings, select the country or region that you want in the Locale list.

    Note   If you select a locale other than English (United States), some date formats will be unavailable when your users fill out forms by using a Web browser. For example, the date format 14-mars-01 is not supported in the French (Belgium) locale. To ensure that you do not use a date format that is not supported, run the compatibility checker before publishing your form template.

Top of Page

Specify the number of decimal places

You can specify the number of decimal places that are displayed only for text box controls that have a decimal data type or for expression box controls that are formatted as a decimal. Changing the number of decimal places affects only the displayed value, and not the value that is saved in the data source.

  1. Double-click the text box control or expression box control whose data you want to format.

  2. In the Control Properties dialog box, do one of the following:

    • If you are using a text box control, click the Data tab.

    • If you are using an expression box control, click the General tab.

  3. Do one of the following:

    • For a text box, ensure that the Data type list displays the appropriate data type, and then click Format.

    • For an expression box, ensure that the Format as list displays the appropriate data type, and then click Format.

  4. In the Decimal places list, under Other options, do one of the following:

    • To display a fixed number of decimal places, select the number of decimal places that you want.

    • To show the number of decimal places that the user types into the control, click Auto.

Top of Page

Change how negative numbers are displayed

You can specify how negative numbers are displayed only for text box controls that have a decimal or whole number data type, or for expression box controls that are formatted to display a decimal or whole number.

  1. Double-click the text box control or expression box control whose data you want to format.

  2. In the Control Properties dialog box, do one of the following:

    • If you are working with a text box control, click the Data tab.

    • If you are working with an expression box control, click the General tab.

  3. Do one of the following:

    • For a text box, ensure that the Data type list displays the appropriate data type, and then click Format.

    • For an expression box, ensure that the Format as list displays the appropriate data type, and then click Format.

  4. In the Display negative numbers like this list, under Other options, select the display style that you want.

Top of Page

Add or remove percent formatting for a number

You can format a text box control or expression box control so that numbers that users type into the box are displayed as percentages. This formatting affects both how values are displayed in a form and how values are saved. This means that any value that is typed into a control with percent formatting will be treated as a percent value.

Notes   

  • InfoPath does not add percent symbols to numbers that are formatted as percentages. To add a percent symbol to a control's label, click where you want the percent symbol to appear, and then type %.

  • You can add percent formatting only to text box controls that have a decimal data type or to expression box controls that are formatted as a decimal.

  1. Double-click the text box control or expression box control whose data you want to format.

  2. In the Control Properties dialog box, do one of the following:

    • If you are using a text box control, click the Data tab.

    • If you are using an expression box control, click the General tab.

  3. Do one of the following:

    • For a text box, ensure that the Data type list displays the appropriate data type, and then click Format.

    • For an expression box, ensure that the Format as list displays the appropriate data type, and then click Format.

  4. In the Decimal Format dialog box, do one of the following:

    • To format the number as a percentage, click Percentage.

    • To remove percent formatting, click Number.

Top of Page

Add or remove a digit grouping symbol in a number

You can add a digit grouping symbol only for text box controls that have a decimal or whole number data type, or for expression box controls that are formatted as a decimal or whole number. Depending on the locale that you select, the separator may separate more or fewer than three digits. Adding or removing a digit grouping symbol affects only the displayed value, not the value that is saved in the data source.

  1. Double-click the text box control or expression box control whose data you want to format.

  2. In the Control Properties dialog box, do one of the following:

    • If you are using a text box control, click the Data tab.

    • If you are using an expression box control, click the General tab.

  3. Do one of the following:

    • For a text box, ensure that the Data type list displays the appropriate data type, and then click Format.

    • For an expression box, ensure that the Format as list displays the appropriate data type, and then click Format.

  4. In the Data Type Format dialog box, do one of the following:

    • To add a digit grouping symbol to the number, select the Use a digit grouping symbol check box, under Other options.

    • To remove a digit grouping symbol from the number, clear the Use a digit grouping symbol check box, under Other options.

Top of Page

Add or remove a currency symbol

You can add currency symbols only for text box controls that have a decimal or whole number data type, or for expression box controls that are formatted as a decimal or whole number. Adding or removing a currency symbol affects only the displayed value, not the value that is saved in the data source.

  1. Double-click the text box control or expression box control whose data you want to format.

  2. In the Control Properties dialog box, do one of the following:

    • If you are using a text box control, click the Data tab.

    • If you are using an expression box control, click the General tab.

  3. Do one of the following:

    • For a text box, ensure that the Data type list displays the appropriate data type, and then click Format.

    • For an expression box, ensure that the Format as list displays the appropriate data type, and then click Format.

  4. In the Data Type Format dialog box, do one of the following:

    • To add a currency symbol, click Currency, and then in the Currency list, select the type of currency that you want to display.

    • To remove a currency symbol, click Number.

Top of Page

Applies To: Office 2010



Was this information helpful?

Yes No

How can we improve it?

255 characters remaining

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!

Support resources

Change language