Advanced Topics

You can increment date parameters and dynamically define a destination file name.

Increment Date Parameters

You can provide expressions in the report's date parameter fields.

If the scheduled report includes date parameters, when you enter values for the schedule dates, you can't change the date values. Every time a scheduled instance of the report is run, the same date parameters are used. If changing the date parameters is required for each run, you can enter an expression in the date parameter field of the scheduler to calculate the date each time the report job runs.

For example, if you create a schedule for a report that runs every Monday to capture data from the previous week, you need to update the date parameters for the report to increment to the first and last days of the previous week.

Enter one of the following functions using the syntax shown to calculate the appropriate date at the scheduled runtime for the report:

  • {$SYSDATE()$} - Current date, the system date of the server on which BI Publisher is running.

  • {$FIRST_DAY_OF_MONTH()$} - First day of the current month

  • {$LAST_DAY_OF_MONTH()$} - Last day of the current month

  • {$FIRST_DAY_OF_YEAR()$} - First day of the current year

  • {$LAST_DAY_OF_YEAR()$} - Last day of the current year

The date function calls in the parameter values aren't evaluated until the report job is processed by the Scheduler.

You can also enter expressions using the plus sign (+) and minus sign (-) to add or subtract days as follows:

  • {$SYSDATE()+1$}

  • {$SYSDATE()-7$}

For this example, to capture data from the previous week, each time the schedule runs, enter the following in the report's date parameter fields:

  • Date From: {$SYSDATE()-7$}

  • Date To: {$SYSDATE()-1$}

You can set up the date functions as default parameter values in the data model. In this case, every time a user views the report from the report viewer, the date parameter is calculated according to the expression supplied for the default value.

Define a Destination File Name Dynamically with a Date Expression

When entering the remote file name for a Web folder or FTP destination, you can enter a date expression to dynamically include a date expression in the file name. The date is set at runtime, using the server time zone.

The date expressions are described in the following table.

Expression Description

%y

Displays the year in four digits: Example: 2011

%m

Displays the month in two digits: 01-12 (where 01 = January)

%d

Displays the date in two digits: 01-31

%H

Displays the hour in two digits based on 24-hour day: 00-24

%M

Displays the minute in two digits: 00 - 59

%S

Displays the number of seconds in two digits: 00 - 59

%l

Displays milliseconds in three digits: 000 - 999

Examples

Use these examples to create a file name that appends a date and a file name that prefixes a date and appends a time.

To create a file name that appends the day, month, and year such as:

myfile_01_11_2010.pdf

Enter the following:

myfile_%d_%m_%y.pdf

To create a file name that prefixes the day, month, and year and appends the hour and minute such as:

01_01_2010_myfile_22_57.pdf

Enter the following:

%d_%m_%y_myfile_%H_%M.pdf

If the file name includes an undefined expression such as my_file_%a%b%c.pdf, the file is created as named my_file_%a%b%c.pdf.