Skip to Content
Technical Articles

‘Dynamic Date’ control in SmartFilter

Dynamic Date is a very useful control within SmartFilter. Dynamic Date is possible ONLY within a SmartFilter. But it is very tricky to get this control to work. I got it to work recently and wanted to share this quick ‘How To’.

Step 1.

Ensure that you have a SmartFilter control

Step 2.

Within the SmartFilter ensure that you have set property ‘useDateRangeType=”true”‘.

Step 3.

Ensure that oData property is of type Edm.DateTime.

Step 4.

Ensure that the date oData property has below annotation

sap:display-format=”Date sap:filter-restriction=”interval

For setting these annotations you can write the below code in MPC_EXT class, DEFINE method.

super->define( ).    
DATA(lo_txt_property) = model->get_entity_type( <EntityType Name> )->get_property( <Property Name> ).  
"DynamicDate Control    
DATA(lo_text_anno) = lo_txt_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).    
lo_text_anno->add( iv_key = 'filter-restriction' iv_value = 'interval')
lo_text_anno->add( iv_key = 'display-format' iv_value = 'Date').

If you are using Fiori OVP

In the app’s manifest/descriptor file

"sap.ovp": {//section for ovp-specific app descriptor settings
	“useDateRangeType”: true, //Flag to enable or disable Dynamic Date. The default value is false.

	“cards”: {  
	“card01”: { 
You must be Logged on to comment or reply to a post.
  • Hi Krishna,

    Thanks for the information.

    It is working as expected without the property "useDateRangeType='true' ", I have just added the annotation in the MPC_EXT.


    Also when I use the property "useDateRangeType='true' ", I am getting invalid property name as shown below:

    "The property or event name does not exist for the control. Please enter the correct property or event name. [SAPUI5: (xml_invalid_property_name)]"



  • Hi Krishna Kishor Kammaje,

    Can you please help me with the below issues related to smart filter.

    1. In one our application we are using normal filter bar, now we are replacing it to smart filter bar, so a separate entity has been created in OData for the list of fields which are required and accordingly I adjusted my xml code in the view and assignee the entity as well, When I load the application no field is coming by default, until and unless i create a smart filter control configuration in view for each field. That means creating control configuration is required for all the fields to display in filter bar can we handle this in OData annotations?
    2. Am using Date range as explained above in my filter bar, as per our requirement in the initialization event of smart filter bar i have to set some default values, previously with help of low and high am setting date in filter bar, now those are not working, I tried in API reference unable to get method information for this control, can you help me providing any sample code for this.

    Thanks in advance for your inputs.

    Rajesh K

  • Hi Rajesh

    Thanks for this blog

    When I try to implement this functionality, some labels of my smartfilterbar disappeared

    Have you ever encounter this issue


  • If you are using oData service based on CDS View (BOPF, ABAP Restfull, exposing CDS views on segw,...) you can use the annotation below on your CDS view to set the annotation sap:filter-restriction=”interval“ on your metadata

    @Consumption.filter.selectionType: #INTERVAL