This article provides step-by-step instructions to generate and display a report for a specific date range using the Run Self-Service Reports and SQL for Confluence apps.
Instructions
Follow these steps:
...
Log into the your Confluence instance.
- Navigate to the required page and click the Edit icon ()click .
- Insert Run with a user form and parameters macro to build the form.
- Click Edit to open the macro settings window.
- In the In Field settings, click +Add field to add additional fields to the form.
a. Since we need a report for a date range, make sure you have Ensure to select Field type as Date for at least two fields with Date type (choose Field type as Date).
b. so as to provide a date range. - Enter the name of the button in the field: the Run button text field. A This ensures that a button with the given text will be is displayed on the form to perform a specific action.
- Click Save settings and Save the page.
The form is displayed as follows: - Insert SQL Query macro under inside the Run with a user form and parameters macro.
- Edit the SQL Query macro to open the settings pop-up.
- Select the required Data source profile from the drop-down.
Enter the SQL statement based on the Field key mentioned in Step# step 5.
In the below following query, used the theCAST
operator is used to convert the literal strings'2003-01-01'
and and'2003-12-31'
to theDATE
toDATE
values.Code Block language sql Select * from tabeltable_name where column_name BETWEEN CAST('$date2' AS DATE) AND CAST('$date1' AS DATE);
- Click Click Save settings and Save the confluence the page.
- Enter the date range or select the dates based on the date format mentioned in Step5 step 5, and click Show Data on the form.
Data is shown as below:
If you enter the incorrect date format, then below error message will be shown.
...
The given example displays the following information:
If the user entered a date in an incorrect format (that is, not in the format as specified in the Date format field in step 5), error messages are shown as:
Info |
---|
The Field key used in the Run self-service report macro will be used in is to input data using the SQL query to input the data. |