I have a grid where I have to set one a column DateTime in ShortDate format (2/18/2009).The fetches data in DataField="MyDate" is in the format with time ( 2/4/2009 7:25:21 PM)
To display only datatime without time I'm using :
<telerik:GridBoundColumn
DataField="MyDate"
HeaderText="Date"
UniqueName="MyDate"
DataFormatString="{0:M/d/yyyy}"
HtmlEncode="false">
</telerik:GridBoundColumn>
.......
but no efect, the data displayed is in the same format with time.
Please help to solve the problem , I need to display datatime without time !!!!!!!
Thanks.
9 Answers, 1 is accepted

I tried setting the DataFormatString for the column as you did and it is working as expected(showing only date and not time). Can you try with a GridDateTimeColumn instead of a GridBoundColumn and see whether it is working.
ASPX:
<telerik:GridDateTimeColumn DataField="MyDate" UniqueName="MyDate" DataFormatString="{0:M/d/yyyy}" HeaderText="Date" ></telerik:GridDateTimeColumn> |
Thanks
Shinu

Thank you very much for your response, but still I have the same issues.
I used property GridDateTimeColumn instead of a GridBoundColumn but no effect.
It very strange because with the same datasource on asp:GridView this format (DataFormatString="{0:M/d/yyyy}" or ="{0:d}") is working !!!!!!!
It’s something wrong with telerik:RadGrid but I don’t know what, I can not remove time from date.
So fare I used:
1). |
<telerik:GridTemplateColumn DataField=" MyDate " HeaderText="Date" UniqueName="MyDate" DataType="System.DateTime"> |
<ItemTemplate> |
<asp:Label ID=" MyDateLabel" runat="server" Text='<%# Eval("MyDate", "{0:M/d/yyyy}") %>'></asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<asp:TextBox ID=" MyDateTextBox" runat="server" Text='<%# Bind("MyDate","{0:M/d/yyyy}") %>'></asp:TextBox> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
2). |
<telerik:GridDateTimeColumn DataField="MyDate" UniqueName="MyDate" |
DataFormatString="{0:M/d/yyyy}" |
HeaderText="Date" > |
</telerik:GridDateTimeColumn> |
3) <telerik:GridBoundColumn
DataFormatString="{0:M/d/yyyy}" HtmlEncode="false">
</telerik:GridBoundColumn> |
but not effect, I mean the date is displayed with time like this: 2/4/2009 7:23:55 PM.
I’m going to be crazy with this telerik grid.
If you have any idea how to dislay date without time, please help !!!!!!
Thank you very much.

Which version of the Grid are you using? Mine is RadControls for AJAX version(2008.3.1314.20). If you are using an older version consider upgrading to the latest version of the Grid. You can also give a try with the Trial version of the Grid available here.
Shinu
I modified your code-snippet:
<telerik:GridBoundColumn DataField="MyDate" DataType="System.DateTime" HeaderText="Date" |
UniqueName="MyDate" DataFormatString="{0:M/d/yyyy}" HtmlEncode="false"/> |
Note that the data type (in the DB) should be DateTime.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

Thank you very much. I managed to solved the issue, now is working.
I used your code:
<telerik:GridBoundColumn DataField="MyDate" DataType="System.DateTime" HeaderText="Date" |
UniqueName="MyDate" DataFormatString="{0:M/d/yyyy}" HtmlEncode="false"/> |
Thanks again.

Here is my code:
<telerik:GridBoundColumn |
SortExpression="DATE_SOUMISSION" |
HeaderText="Date soumission demande" |
DataField="DATE_SOUMISSION" |
UniqueName="DATE_SOUMISSION" |
DataType="System.DateTime" |
ReadOnly=true htmlEncode="False" DataFormatString={0:dd/MM/yyyy}> |
</telerik:GridBoundColumn> |
Message d'erreur de l'analyseur: Le contenu littéral ('<telerik:GridBoundColumn
SortExpression="DATE_SOUMISSION"
HeaderText="Date soumission demande"
DataField="DATE_SOUMISSION"
UniqueName="DATE_SOUMISSION"
DataType="System.DateTime"
ReadOnly=true htmlEncode="False" DataFormatString={0:dd/MM/yyyy}>
</telerik:GridBoundColumn>') n'est pas autorisé dans un 'Telerik.Web.UI.GridColumnCollection'.
Which means that GridBoundColumn etc.. is not autorised in a 'Telerik.Web.UI.GridColumnCollection'.
Any Idea?
Maybe it could help to know that my HtmlEncode is underline in green and says that it is not a validated attribute of GridBoundColumn...
Thank you

I forgot the double quote around the dataformatstring value!
Thanks anyway

I tried adding the namespace in my xaml for mscorlib but no luck.
<tlk:GridViewDataColumn DataMemberBinding="{Binding TradeDate}" DataType="System.DateTime"
Width="70" DataFormatString="{}{0:M/dd/yyyy}"
UniqueName="TradeDate" >
<tlk:GridViewDataColumn.Header>
<TextBlock Text="Trade Date" TextWrapping="Wrap" />
</tlk:GridViewDataColumn.Header>
</tlk:GridViewDataColumn>
I suppose this is a Silverlight-related question. If this is so, can you please re-post this in our Silverlight forums?
Regards,
Daniel
the Telerik team