DateTimePicker: Select Month and Day without Year

10 posts, 1 answers
  1. Jason
    Jason avatar
    15 posts
    Member since:
    Jul 2010

    Posted 02 Jan 2012 Link to this post

    I'm building a rules engine that allows date constraints.  I want to be able to use a datetime picker to select the month and day, but I don't want to show the year.  Is this possible with your control?

    Jason
  2. Dani
    Admin
    Dani avatar
    848 posts

    Posted 03 Jan 2012 Link to this post

    Hi Jason,

    I think what you need is simply custom formatting for the display date. Please, check the Formatting help article on RadDateTimePicker. I hope it helps. 


    Greetings,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. Jason
    Jason avatar
    15 posts
    Member since:
    Jul 2010

    Posted 03 Jan 2012 Link to this post

    Thanks Dani.

    I am currently doing that, but I need the year not to show at the top of the calendar when the picker is clicked.  Attached is a picture of what I mean.
  4. Answer
    Dani
    Admin
    Dani avatar
    848 posts

    Posted 04 Jan 2012 Link to this post

    Hello Jason,

    You can then use the MonthViewHeaderFormat and assign it via the CalendarStyle property of RadDateTimePicker:

    <Style x:Key="CalendarStyle" TargetType="telerik:RadCalendar">
        <Setter Property="MonthViewHeaderFormat" Value="MMMM" />            
    </Style>

    I hope this will help solve the issue.

    Regards,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  5. Siham
    Siham avatar
    5 posts
    Member since:
    Mar 2019

    Posted 12 Mar in reply to Dani Link to this post

    Hello, Don't know if Jason has his problem solved, but I am in the same case, need to not show the Year on my DatePicker (only month and day).

     

    I've tried the solution above but it doesn't work.

    Thanks for your help

  6. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2093 posts

    Posted 14 Mar Link to this post

    Hello Jason,

    I've tested the Daniela's solution and its works like a charm. Only the month is shown. However, if you want to show also the day you will need to use a bit different format. For example "MMMM - ddd" or "MMMM - d". I've attached a small example showing this approach. I hope it helps.

    Regards,
    Martin Ivanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  7. Siham
    Siham avatar
    5 posts
    Member since:
    Mar 2019

    Posted 14 Mar Link to this post

    Hello, thanks for answering.

    It effectively works but only on a RadCalendar, but as I need to use a RadDatePicker, this does'nt give any possibility to use the property.

    Thank you for your help. As I am a biginner I maybe need more assistance :)

  8. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2093 posts

    Posted 14 Mar Link to this post

    Hello Siham,

    It seems that I am missing something here. Yes, the property is defined on the RadCalendar control which is used both in RadDateTimePicker and RadDatePicker. Both controls have the CalendarStyle property which you can use to set the MonthViewHeaderFormat property of the calendar. I've only changed the type of the control in my project from RadDateTimePicker to RadDatePicker and the format still works.
    <telerik:RadDatePicker VerticalAlignment="Center" HorizontalAlignment="Center">
        <telerik:RadDateTimePicker.CalendarStyle>
            <Style TargetType="telerik:RadCalendar">
                <Setter Property="MonthViewHeaderFormat" Value="MMMM - d" />
            </Style>
        </telerik:RadDateTimePicker.CalendarStyle>
    </telerik:RadDatePicker>
    Can you please tell me what am I missing? Also, can you send me a picture of the expected result?

    As a small note on the CalendarStyle property, keep in mind that the RadDatePicker control hosts a RadCalendar (shown when the popup opens). The CalendarStyle property allows you to define a Style that will be passed to the RadCalendar control when the popup opens.

    Regards,
    Martin Ivanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  9. Siham
    Siham avatar
    5 posts
    Member since:
    Mar 2019

    Posted 14 Mar Link to this post

    Hello, It works now, thank you

    The difference was on the calendarstyle part, I was using RadDatePicker instead of RadDateTimePicker, now it works :)

     

  10. Jason
    Jason avatar
    15 posts
    Member since:
    Jul 2010

    Posted 14 Mar in reply to Martin Ivanov Link to this post

    Thanks guys.  I don't remember asking the question (it was 7 years ago), but since I marked Dani's answer as the "Answer" I guess it was correct.  The solution looks reasonable.
Back to Top