Skip to Content
Author's profile photo Former Member

When to not use sap.m.DatePicker: How to cleanly pick a month instead of a date

Hello fellow SAPUI5 learners and experts,

A quick tip regarding input fields and dates. I was trying to have an input field that allows a user to select a date as a month.

I used a sap.m.DatePicker with the displayFormat as below, to select a month period.


This worked well enough; the DatePicker field showed the date as expected and is treated as I wanted.


However I still had to click down to the day in the picker view:


For example, I still had to click all the way through to 16th (or whatever) April 2015 to select April 2015. One extra click felt inelegant, how could I avoid it?

It turns out that using sap.m.DateTimeInput was the more correct choice in this instance!


leads to:


The date picked will implicitly always be the 1st day of the  chosen month.

No doubt not much of an observation to our UI5 veterans, but a learning item for me!

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sven Ringling
      Sven Ringling

      Interesting UI5 nugget.
      Are there similar codes for date + time?

      Author's profile photo Vicente Veiga
      Vicente Veiga

      Now that sap.m.DateTimeInput is deprecated since 1.32.8 version, SAP recommends to use sap.m.DatePicker instead.

      Does anyone know how to modify the day/month/year calendar to a month/year calendar in sap.m.DatePicker?



      Author's profile photo Parth Budhiraja
      Parth Budhiraja

      Hi Vicente,


      Did you find anything relevant to sap.m.DatePicker?




      Author's profile photo Rohan De Alwis
      Rohan De Alwis


      Please inform if anyone had an answer for month/year calendarĀ using sap.m.DatePicker?

      Author's profile photo Neil Ward
      Neil Ward

      Is this still not resolved... ?

      I also need to know to how to do individual year / month / week usingĀ sap.m.DatePicker

      Author's profile photo Ralf Schoenfeld
      Ralf Schoenfeld

      Hi All,

      I had the same question and found the following control for month selection:


      Author's profile photo Boghyon Hoffmann
      Boghyon Hoffmann

      With UI5 1.68+, DatePicker can now also handle picking month/year or year only. See: