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

Changing DateFormat

5 Answers 293 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Namir Ahmed
Top achievements
Rank 1
Namir Ahmed asked on 21 Sep 2009, 09:34 PM
Hi,

How do I set the DateFormat in the RadDatePicker.

For example, I want to show the date 9/7/09 as July 9, 2009 in the textbox. Any help would be appreciated.

Thanks,
wpfguy

5 Answers, 1 is accepted

Sort by
0
Namir Ahmed
Top achievements
Rank 1
answered on 21 Sep 2009, 09:43 PM
I figured it out. Thanks.
0
liza g
Top achievements
Rank 1
answered on 03 May 2010, 08:57 AM
How did you do that?
0
Boyan
Telerik team
answered on 05 May 2010, 02:59 PM
Hello liza g,

 You can try the following code:

CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.DateTimeFormat.ShortDatePattern = "MMM/dd/yyyy";
datePicker1.Culture = culture;

This will set the date to this format : May/06/2010.

Let me know if you have more questions.

Sincerely yours,
Boyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
liza g
Top achievements
Rank 1
answered on 05 May 2010, 04:23 PM
but I have to do it from the XAML, 
cause it's a DatePicker in a DataTemplate inside a gridView
and if I set it a name, it's not recognize in the cs file.
here is my code:
<telerik:RadGridView>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn
  <telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding myDate}" />
 </DataTemplate>
 </telerik:GridViewDataColumn.CellTemplate>

<telerik:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
<telerikInput:RadDatePicker Loaded="Editor_Loaded" 
SelectedDate="{Binding myDate, Mode=TwoWay}"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
<telerik:RadGridView>
0
Kaloyan
Telerik team
answered on 10 May 2010, 12:06 PM
Hello liza g,

You can set a global culture that will be applied to the RadDatePicker also.

CultureInfo culutreInfo = System.Threading.Thread.CurrentThread.CurrentCulture.Clone() as CultureInfo;
culutreInfo.DateTimeFormat.ShortDatePattern = "MMM dd/yyyy";
System.Threading.Thread.CurrentThread.CurrentCulture = culutreInfo;

Best wishes,
Kaloyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
DatePicker
Asked by
Namir Ahmed
Top achievements
Rank 1
Answers by
Namir Ahmed
Top achievements
Rank 1
liza g
Top achievements
Rank 1
Boyan
Telerik team
Kaloyan
Telerik team
Share this question
or