This article provides step-by-step instructions to generate and display a report for a specific date range using Run Self-Service Reports and SQL for Confluence apps.
Instructions
Follow these steps:
Log into the Confluence instance.
- Navigate to the required page and click the Edit icon ().
- Insert Run with a user form and parameters macro to build the form.
- Click Edit to open the macro settings window.
- In the 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 at least two fields with Date type (choose Field type as Date).
b. Enter the name of the button in the field: Run button text. A button with the given text will be displayed on the form to perform a specific action. - Click Save settings and Save the page.
- Insert SQL Query macro under 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# 5.
In the below query, used theCAST
operator to convert the literal strings'2003-01-01'
and'2003-12-31'
to theDATE
values.Select * from tabel_name where column_name BETWEEN CAST('$date2' AS DATE) AND CAST('$date1' AS DATE);
- Click Save settings and Save the confluence page.
- Enter the date range based on the date format mentioned in Step5 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 field key used in the Run self-service report macro will be used in the SQL query to input the data.