Is there any way possible to set a UIDatePicker in XCode-Interface Builder to just use the rollers of the "month" and "year" without the "day"? I've tried checking the file properties in the IB yet failed to find a solution for my problem...
-
You need to change the mode of date picker to "date" instead of date and time. – Abdul Rehman Butt May 29 '13 at 06:17
-
1@Abdul Rehman Butt , it is no use, it show year-month-day. we just want to show year and month. – aircraft Dec 02 '16 at 06:36
8 Answers
Your question mentions date
and year
so I it seemed like UIDatePickerModeDate
would suffice but as you are looking for month
and year
which is not an available option. I suggest you consider using a two component UIPickerView
object.
Original Answer
You can do this by changing the Mode
property under Date Picker
to Date
in the Attributes Inspector
in the right bar ( Cmd + Option + 4 ). You can also do this programmatically,
datePicker.datePickerMode = UIDatePickerModeDate;

- 44,595
- 12
- 101
- 105
-
4Thanks Deepak, but this mode shows the "day" roller as well... I would like to only display the Month and Year. – BearDroid Jun 13 '11 at 09:15
-
UIDatePickerModeDate - Displays month, day, and year depending on the locale setting (e.g. November | 15 | 2007) – patrick-fitzgerald Apr 04 '13 at 02:00
-
@PaulJohnParreno Hello, Have You Found solution on How to show only Year or Month ? – iFateh Jun 03 '22 at 11:04
I don't think this is possible using the standard UIDatePicker. If you have a look at the documentation it makes it clear that only four modes are available:
- UIDatePickerModeTime,
- UIDatePickerModeDate,
- UIDatePickerModeDateAndTime,
- UIDatePickerModeCountDownTimer
You may have to create your own.

- 1,496
- 13
- 21
I have rewrote MonthYearPicker project with custom minDate, maxDate, blurred effect background and show up picker animation: MonthYearPicker

- 726
- 8
- 12
What you can do is restrict the range of dates, that can be used for input using the properties maximumDate and minimumDate
This has the added benefit of being automatically localized. i.e. the order of month and day is correct.

- 18,946
- 4
- 59
- 50
The question has been answered but for someone who is looking for a UIComponent that selects only month and year, there is a tool at github that can be used:

- 9,369
- 1
- 27
- 33
You can use Third Party custom Date Picker as iOS Default Date Picker do not provide one.
Try https://github.com/nairteashop/NTMonthYearPicker.
Worked for me

- 1
- 2