This is a migrated thread and some comments may be shown as answers.

How to pick Feb 29 in DateTimePicker without specifying the year

1 Answer 607 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
SPE
Top achievements
Rank 1
SPE asked on 27 Feb 2013, 07:50 AM
Hi,

I made a customized version of DateTimePikcker in a way that it displays month and day only (MM-dd),  as I needed to display the month and day parts as a separate field from the year component.

So far it's worked all fine - for input dates with yy-MM-dd or MM-dd formats.

The problem is that it's impossible to display the date '02-29' without specifying the year.

That is, unless I type in the date using the yy-MM-dd (where yy is the leap year), DateTimePicker does not support Feb 29 so I have to type something like 2014-02-29.

Is there any way to type and display 02-29 without the user actually having to specify the year?

Thank you in advance for your kind reply.

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

                            <telerik:RadDateTimePicker Grid.Column="1" Grid.Row="8"
                                                       x:Name="birthDate"
                                                       InputMode="DatePicker"
                                                       CalendarStyle="{StaticResource CalendarStyle}" 
                                                       TextAlignment="Right"
                                                       Height="16"
                                                       Margin="2,0"
                                                       DateTimeWatermarkContent="Enter a Date"
                                                       SelectedDate="{Binding CurrentIndividual.BirthDateTime, Mode=TwoWay}"/>

1 Answer, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 01 Mar 2013, 02:54 PM
Hi Sunmig,

I don't think that this will be possible. The thing is that even that you have hidden the year, in the background the entry is parsed to a DateTime. When you write 02-29 this is parsed as 02-29-2013 and as this year there is no 29 th of February the parsing fails.So the SelectedValue is of type DateTIme, so there is always an year part and if you don't specify the year it automatically takes the current year.

The only thing that you can do is to use custom parsing as shown in this help article, but you will still have to specify an year, but you can specify one that have 02-29.

Hope this helps.

All the best,
Boyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DateTimePicker
Asked by
SPE
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Share this question
or