Example of a Report without any Format
The ESQL that Spira platform uses DateTime to store date. As a result, any field storing Date data also supports storing the time value. When no formatting is applied on the date field, then, the report appears like the following.
As you can see in the diagram above, there is also timestamp component. But, if you want the date to be formatted like "DD-MON-YYYY", then, the ESQL query needs to be customized for every date field. If multiple date fields are available, then the translations may be exhaustive and it is better to use the XSLT to be used. Please refer to an earlier KB article "Formatting Date using XSLT" on how this can be done.
This article assumes that you are using the ESQL to format the query to display the date in the "DD-MON-YYYY" format.
Creating the SQL Query for the Graph
- From the administration panel, go to the "Edit Reports"
- Add a new Report and give it a name.
- Provide details on the header, footer, description as necessary
- Confirm selection for category and format (ensure HTML and Excel are available as this is a tabular report)
- Click on "Add New Custom Section" in the Custom Sections.
- Give a name to the custom section
- Write the SQL Query as follows
- You can preview the results to see if there are any errors in the query.
- Click on "Create Default Template" to create the XSLT transformation required for rendering the report
- Save the Custom Section
- Save the Report
- Run the Report from the Reporting area
Date formatted SQL Query
The date formatted SQL query is given below.
(Cast(Day(R.CREATION_DATE) as string)
+ "-" +
WHEN (Month(R.CREATION_DATE)) = 1 THEN "JAN"
WHEN (Month(R.CREATION_DATE)) = 2 THEN "FEB"
WHEN (Month(R.CREATION_DATE)) = 3 THEN "MAR"
WHEN (Month(R.CREATION_DATE)) = 4 THEN "APR"
WHEN (Month(R.CREATION_DATE)) = 5 THEN "MAY"
WHEN (Month(R.CREATION_DATE)) = 6 THEN "JUN"
WHEN (Month(R.CREATION_DATE)) = 7 THEN "JUL"
WHEN (Month(R.CREATION_DATE)) = 8 THEN "AUG"
WHEN (Month(R.CREATION_DATE)) = 9 THEN "SEP"
WHEN (Month(R.CREATION_DATE)) = 10 THEN "OCT"
WHEN (Month(R.CREATION_DATE)) = 11 THEN "NOV"
WHEN (Month(R.CREATION_DATE)) = 12 THEN "DEC"
+ "-" +
Cast(Year(R.CREATION_DATE) as string)) as Date
SpiraTestEntities.R_Incidents as R
- To format the date in a specific date format like (DD-MON-YYYY) format, the built-in Day (DD), Month (MM), and Year (YYYY) functions have to be used to extract the date, month, and year part of the date. These functions return DD, MM, and YYYY as an Int32 datatype.
- Once the parts of the date are extracted, they will have to be converted as a string using the CAST operator.
- A CASE / WHEN logic is then applied for month to translate the month (DD) in numeric form to the 3-character Month (MON) format.
- The string components for date, month, and and year are now concatenated using the "+" operator sprinkling the field separator (-) to make them look like "DD-MON-YYYY" format.
Here is the sample of the report output. The final column shows how the CREATION_DATE has been formatted.