Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > DatePicker > Change DatePicker Date Format

Not answered Change DatePicker Date Format

Feed from this thread
  • Shehnaz avatar

    Posted on May 27, 2011 (permalink)

    Hi...
    Can u tell me way where i can change the Date format of the control in XAML. I m following MVVM pattern. Is dere any inbuilt property by which we can directly change d date format...???
    Plz reply ASAP.
    Thanx n regards
    Shehnaz Khan.

    Reply

  • Yana Yana admin's avatar

    Posted on Jun 1, 2011 (permalink)

    Hello Shehnaz,

    Please check this help article which explains how the date can be formatted in RadDateTimePicker. Unfortunately, you can define a custom format only in code-behind.

    Regards,
    Yana
    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

    Reply

  • Vinod avatar

    Posted on Jan 4, 2012 (permalink)

    We have used cultute info to rad datepicker using the folloing code:
                CultureInfo ldtPckrcultureInfo = new CultureInfo("en-US");
                DateTimeFormatInfo dateInfo = new DateTimeFormatInfo();
                dateInfo.ShortDatePattern = "MM-dd-yy";
                ldtPckrcultureInfo.DateTimeFormat = dateInfo;
                dtpStartDate.Culture = ldtPckrcultureInfo;

    This was working fine.
    But when we try to enter date manually into the date picker, the order of month, day and year gets changed.
    On manually adding the date value in date picker, it takes the date in the different format (dd-yy-mm)
    For example, if we enter 04-06-12 (6th April 2012), it becomes 12-06-04 (12th June 2004).
    If we enter 04-15-12 (15th April 2012), we get error.

    If we change an existing value, suppose,  01-11-12  to 01-10-12 , it becomes 10-12-01 .


    Reply

  • Ivo Ivo admin's avatar

    Posted on Jan 6, 2012 (permalink)

    Hi,

    The DateTimeFormat.DateSeparator property is the key to resolving this issue. If you set it to "-" your code should work great. However I would recommend you not to create a new instance of DateTimeFormat class, because this will cause the RadDateTimePicker to be in invariant culture . Here is the recommended code for your scenario:
    this.RadDateTimePicker.Culture = new CultureInfo("en-US");
    this.RadDateTimePicker.Culture.DateTimeFormat.ShortDatePattern = "MM-dd-yy";
    this.RadDateTimePicker.Culture.DateTimeFormat.DateSeparator = "-";

    All the best,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > DatePicker > Change DatePicker Date Format
Related resources for "Change DatePicker Date Format"

WPF DatePicker Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]