DATE_RANGE

A Date_Range field is a combination of a start date and end date field. In the Book Model, PublishingPeriod field is configured as a date range. In the database this field is split into two columns publishing_period_start and publishing_period_end. To configure a Date range field either in filter or retrieval criteria, set the field type as DATE_RANGE and configure the DateRange mapping to map the field with the SQL parameter.

Following is an example of display a date_range field.

Include the date range columns in the select clause. In the following example, publishing_period_start_date and publishing_period_end_date which is a date range field from the book model is illustrated.

select publishing_period_start_date PUBLISHING_PERIOD_START, publishing_period_end_date PUBLISHING_PERIOD_END FROM ZBKS_Book

The retrieval should be defined as follows:

<CustomRetrievalField>
<FieldRef levelType="ZBKS.Book" category="PDF">
<FieldName>Promotional Period</FieldName>
</FieldRef>
<Type>DATE_RANGE</Type>
<DateRangeMapping fromSqlName="PROMOTIONAL_PERIOD_START_DATE" toSqlName="PROMOTIONAL_PERIOD_END_DATE"/>
</CustomRetrievalField>

Following is an example to filter a date_range field.

Include the date range columns in the where clause. In the following example, promotional_period_start_date and promotional_period_end_date which is a date range field from the book model is illustrated.

where ${filterIfNotNull:PROMOTIONAL_PERIOD_START_DATE,promotional_period_start_date <= $PROMOTIONAL_PERIOD_START_DATE$}
and ${filterIfNotNull:PROMOTIONAL_PERIOD_END_DATE,promotional_period_end_date >= $PROMOTIONAL_PERIOD_END_DATE$}

The filter should be defined as follows:

<CustomFilterField>
<FieldRef levelType="ZBKS.Book" category="PDF">
<FieldName>PromotionalPeriod</FieldName>
</FieldRef>
<Type>DATE_RANGE</Type>
<DateRangeMapping fromSqlName="PROMOTIONAL_PERIOD_START_DATE" toSqlName="PROMOTIONAL_PERIOD_END_DATE"/>
</CustomFilterField>

Following are the key points to note:


  • LevelType in the FieldRef is pointed to Book, which is where the PublishingPeriod field is defined.

  • Field Category is set to PDF(PreDefined Field)

  • Type is set as DATE_RANGE (Note the capital letters)

  • DateRangeMapping is defined in the CustomRetrievalField

  • DateRangeMapping contains fromSqlName for the start date SQL parameter and toSqlName for the end date SQL parameter

localFormat attribute can also be used with DATE_RANGE filter type. The developer can add a localFormat definition in the DateRangeMapping tag and both "from" and "to" values will be converted into numeric values. Please refer to the DATE filter type to get more information on localFormat attribute.

<CustomFilterField>
<FieldRef levelType="Undefined" category="PDF">
<FieldName>PromotionalPeriod</FieldName>
</FieldRef>
<Type>DATE_RANGE</Type>
<DateRangeMapping fromSqlName="PROMOTIONAL_PERIOD_START_DATE_NMBR" toSqlName="PROMOTIONAL_PERIOD_END_DATE_NMBR" localFormat="yyyyMMddHH"/>
</CustomFilterField>