By applying a datatype to a date in Relatics, an end user is able to select a date from a date picker in an easy and intuitive way. In reporting information, there are often special needs related to displaying the date. For example, using a specific format to display the date. In this article, I will explain how you can best configure this in a report.
Configuring a datatype for a date
In the information model you can set the datatype of a property to ‘Date’ (read more about: Property details). This setting ensures that end users can only enter valid values according to a date format. In the image below you can see that the propery ‘Deadline’ is configured to the datatype ‘Date’:
Checking if a value is a valid date in the StyleVision report
With Altova StyleVision you can design the report and display the date. A tip here is to use a condition for the date, with which you check whether the value is really a date. If you do not do this then, in a case of an empty value for a date, an error message or the value ‘NaN-NaN-NaN’ is displayed. The value ‘NaN’ means ‘Not-a-Number’. Below is an example of how you can configure the condition to solve this problem:
The following XPath Expression is applied to the condition, which checks whether the value (example: ‘Deadline’) is a valid date:
Example XPath Expression: Check if the value is a valid date
@Deadline castable as xs:date
With ‘castable as’ you can check whether a value (example: ‘Deadline’) meets a certain data type (example: ‘xs:date’).
Configuring a format for the date in the StyleVision report
For the date (example: ‘Deadline’) you can use right click on ‘(content)’ and choose ‘Edit Value Formatting…’ to select the desired format from the selection list. If you do not want spaces in the format, then the tip is to use double quotes for the dashes. In the example below you can see how to set the format for ‘dd-mm-yyyy’ (example: ’12-02-2018’):
Of course there are several possibilities to display a date. For example, with the format ‘DD Month YYYY’ you can display the month in text (example: ’12 February 2018’).
The end result
If we look in Relatics, then you can see how an end user can select a date from a date picker in an easy and intuitive way:
In generating the report in Relatics, the date is displayed according to the desired format (example: the requirement ‘REQ-0001’ contains the value ’12-02-2018’). If no value for date has been entered by the end user, nothing will be shown (example: the requirement ‘REQ-0002’ does not show a value for the date).
Upload the RCS file below to your Relatics environment to view the examples contained in this article:
About Kris de Waal
After graduating in Business Administration with a specialization in Business Information Management, Kris joined Relatics as a Business Information Consultant. He is eager to learn about new concepts, technologies, IT systems and apply the knowledge in his daily work. In addition, Kris loves to work on new ideas and innovations to get more out of Relatics.
Do you need help in applying the techniques and tips in your own case? Or do you have questions, comments or suggestions about this article? If so, don’t hesitate to contact one of our consultants