telerik:GridDateTimeColumn date display format?

7 posts, 1 answers
  1. Darren
    Darren avatar
    44 posts
    Member since:
    Sep 2008

    Posted 19 Nov 2008 Link to this post

    Hi,

    I'm betting this is so simple that i'm overlooking things. Currently my dates are being stored as:

    "2008/11/08 12:00:00 AM"

    The format i'm wanting it to be displayed as should be:

    "08 November 2008 12:00:00 AM" or "08/11/2008 12:00:00 AM"

    The time whether displayed or not is not that important at the moment.
    Thanks,
  2. Answer
    Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 19 Nov 2008 Link to this post

    Hello Darren,

    Test the following:
    <telerik:GridDateTimeColumn DataField="ShippedDate" DataType="System.DateTime"
        DataFormatString
    ="{0:dd MMMM yyyy hh:mm tt}" 
        HeaderText="ShippedDate" SortExpression="ShippedDate" UniqueName="ShippedDate"
    </telerik:GridDateTimeColumn> 

    Let me know if you need more information.

    Kind regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Darren
    Darren avatar
    44 posts
    Member since:
    Sep 2008

    Posted 19 Nov 2008 Link to this post

    You rock!
  5. Abid
    Abid avatar
    1 posts
    Member since:
    May 2015

    Posted 19 Aug 2015 Link to this post

    You can use regular telerik:GridBoundColumn but then you have to add "DataType="System.DateTime" too as following:

    <telerik:GridBoundColumn DataField="DateAdded" DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime" HeaderText="Date Added" ></telerik:GridBoundColumn>

  6. Salman
    Salman avatar
    6 posts
    Member since:
    Feb 2016

    Posted 21 Feb Link to this post

    I used Above solutions and it works fine but when I want to assign that data to a raddatepicker , It only works if I use "DataFormatString="{0:MM/dd/yyyy}" .

    when I'm using below format:

    <telerik:GridBoundColumn DataField="Order_Date" FilterControlAltText="Filter Order_Date column" HeaderText="Order Date"
    UniqueName="Order_Date" EmptyDataText=""
    DataFormatString="{0:dd/MM/yyyy}" DataType="System.String">

    which is English format, I receive error that "System.FormatException: String was not recognized as a valid DateTime."

    DateTime orderdate1 =Convert.ToDateTime(SelectedItem["Order_Date"].Text);// receive error for this line
    DatOrderDate.SelectedDate = orderdate1; //Datorderdate is a raddatepicker

  7. Salman
    Salman avatar
    6 posts
    Member since:
    Feb 2016

    Posted 25 Feb Link to this post

    Any solution for this issue? let me know if further explanation required .
  8. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 25 Feb Link to this post

    Hi Salman,

    It means that the value you are trying to parse (SelectedItem["Order_Date"].Text) is not a valid DateTime representation. Please make sure that the value returned can be successfully parsed to DateTime object:
    https://msdn.microsoft.com/en-us/library/system.datetime.parse%28v=vs.110%29.aspx
    https://msdn.microsoft.com/en-us/library/ch92fbc1%28v=vs.110%29.aspx

    Generally, if you will create a column for a DateTime field, you can use a GridDateTimeColumn with DataType="System.DateTime" and add your desired DataFormatString.

    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017