Change DatePicker Date Format

4 posts, 0 answers
  1. Shehnaz
    Shehnaz avatar
    3 posts
    Member since:
    May 2011

    Posted 27 May 2011 Link to this post

    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.
  2. Yana
    Yana avatar
    4604 posts

    Posted 01 Jun 2011 Link to this post

    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.

    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
  3. Vinod
    Vinod avatar
    16 posts
    Member since:
    Nov 2011

    Posted 04 Jan 2012 Link to this post

    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 .

  4. Ivo
    Ivo avatar
    390 posts

    Posted 06 Jan 2012 Link to this post


    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,
    the Telerik team

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

Back to Top