telerik:GridDateTimeColumn date display format?

2 Answers 8012 Views
Grid
Darren
Top achievements
Rank 2
Darren asked on 19 Nov 2008, 09:19 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 19 Nov 2008, 09:42 AM
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.
Darren
Top achievements
Rank 2
commented on 19 Nov 2008, 09:47 AM

You rock!
0
Abid
Top achievements
Rank 1
answered on 19 Aug 2015, 08:52 PM

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>

Salman
Top achievements
Rank 1
commented on 21 Feb 2016, 01:12 PM

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

Salman
Top achievements
Rank 1
commented on 25 Feb 2016, 06:00 AM

Any solution for this issue? let me know if further explanation required .
Eyup
Telerik team
commented on 25 Feb 2016, 06:23 AM

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
Tanu
Top achievements
Rank 1
commented on 21 Apr 2018, 06:28 PM

Hello. I am looking for this format (4/25/2018  12:00 AM/PM) dd/mm/yyyy hh:mm AM/PM)

I tried the solution which you have provided but didnot work for me.

 

tried with the below formats  .Instead of AM or PM in export to excel its displaying as tt. I have also mentioned .Please help me soon

 DataType="System.DateTime"

DataFormatString="{0:dd MMMM yyyy hh:mm tt}"

  DataFormatString="{0:MM/dd/yyyy hh:mm tt}" 

Teng
Top achievements
Rank 1
commented on 17 Jan 2019, 06:33 PM

Is there a way to easily handle displaying date-time columns according to when PDT (Pacific Daylight Saving Time) and PST (Pacific Standard Time) is being observed?

 

Thank you in advance

Eyup
Telerik team
commented on 22 Jan 2019, 09:17 AM

Hi Teng,

Generally, you can set the DateFormatString property of the column to set a specific formatting similar to the attached web site sample.

You can modify this property manually depending on your Culture and selected DateTime mode, however, this will probably require a RadGrid1.Rebind() call to refresh the grid content.

Instead, on PreRender event handler of the grid you can traverse its Items collection and set the text manually to the cells using code-behind formatting pattern either with C# or VB.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Ciupaz
Top achievements
Rank 2
Veteran
commented on 08 Jul 2020, 05:30 PM

In my 

For Each item As GridDataItem In grdPosizioniFisse.Items

....

how can I set the PubDate with day name before?

For example, If I have 08/07/2020 in the header (I have date fields in columes header),
I should get Mer 08/07/2020 (in Italian language). 

Thanks a lot. 

Luis

Eyup
Telerik team
commented on 13 Jul 2020, 03:54 PM

Hello Luis,

 

I've already replied to your query in the following thread:
https://www.telerik.com/forums/format-date-with-day-name-in-headers

I suggest that we continue our technical conversation there.

 

Regards,
Eyup
Progress Telerik

Tags
Grid
Asked by
Darren
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Abid
Top achievements
Rank 1
Share this question
or