Configure The Page Info Control to Display a Date

There are two ways to add a date to a print template:

Both methods allow you to use format strings to format dates. The table below shows some predefined format strings. To see the full list, open the properties for a Page Info or Label control and click the icon in the Actions | Text Format String box. Select a format to preview it.

Examples of Date-Time Format Strings

Description

Format String

Example Output

Format strings that show the date and time

dddd, MMMM d, yyyy h:mm:ss tt

d MMMM, yyyy HH:mm:ss

yyyy-MM-dd HH:mm

Monday, January 14, 2019 16:42:30

14 January, 2019 04:42:30 PM

2019-01-14 16:42

Format strings that show the date only

MM/dd/yyyy

yyyy-MM-dd

MMMM d, yyyy

01/14/2019

2019-01-14

January 14, 2019

Format strings that show the time only

HH:mm

h:mm tt

18:10

4:42 PM

Use the Page Info Control to Add the Current Date

The Page Info control has an option to add the server's current date and time to the print template.

By default, the Page Info control displays the date using the format dddd, MMMM d, yyyy, for example, Friday, February 22, 2019. You can use the control's Text Format String property to control how the date is presented and whether the time is shown.

To use the Page Info control to add the current date to a print template:

  1. Add a Page Info control to the layout.

  2. In the Actions section of the Properties panel, select Current Date and Time from the Page Information drop-down list.

  3. Click the icon in the Text Format String box and select the format you want to use.

    Preview of the selected format

  4. Click OK.

  5. Click Preview to verify the date and format.

    Print output showing the formatted output of a Page Info control

Use a Date-Time Function to Add a Date

Print Designer offers date-time functions that allow you to add dates to print templates. The date's value is determined at run time, so the date must be configured in an expression.

By default, date-time functions return the date and time in the format dd/MM/yyyy hh:mm:ss, for example, 02/19/2019 16:42:30. For more information see Date-Time Functions. You can configure the control's Text Format String property to format the date. Alternatively, you can use the FormatString() function. For more information see String Functions.

To add a date to a print template:

  1. Drag a Label control to the layout.

  2. In the Actions area of the Properties panel, click the icon in the Expression box to open the Expression Editor.

    Open the Expression Editor to configure an expression for a Label control

  3. In the pane at the lower left, expand Functions and select Date-time.

  4. Search for a function and view its description:

    1. In the search box, type the search text, for example, Now.

      The center pane lists the functions with "Now" in their name.

    2. Select one of the functions.

      A description of the function appears in the right pane.

      Description of the selected function

    3. Click the icon in the search box to remove the search filter.

  5. Double-click the date-time function that you want to use, or type it in the top pane.

    The top pane shows the expression you are building. In this case, the expression consists only of the function reference.

  6. Click OK.

    The expression appears in the Expression box in the Properties panel and in the Label control on the design surface. The icon in the Label control indicates that the value will be determined when the print is generated.

    Example of a date-time function in a Label control

  7. In the Properties panel, click the icon in the Text Format String box to open the Format String Editor.

  8. Select the format that you want to use.

    Preview of the selected format

    The Text Format String property cannot format complex expressions like 'Printed ' + Today(). If you want to combine text with a date format, use the FormatString() function in the expression. For example, the following expression prints "Printed " followed by the date:

    FormatString('Printed {0:MMMM d, yyyy H:mm}', Now())     ®     Printed February 19, 2019 19:02

  9. Click OK.

  10. Click Preview to preview the print.

    Formatted date and time in the output