This is a migrated thread and some comments may be shown as answers.

RadGridView Date column display with no time

2 Answers 1447 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arun
Top achievements
Rank 1
Arun asked on 01 Oct 2011, 12:23 AM
Hello Telerik Team,
I am new to Telerik. we are upgrading the project to 2011 version. In the RadGridview we have a date column display. It was working fine in the 2009 version. Now it is displaying the date with default time 12:00. How do I take out the time part and display only the date.
I have used the  DataFormatString = "{0: mm/dd/yyyy}. I could see the format change in the result. But the months are always showing 00 for all the row. What is the correct syntax? I tried this format DataFormatString = {mm/dd/yyyy} , getting error in the page load itself.
<telerik:GridViewDataColumn DataType="{x:Null}" IsReadOnly="True" IsVisible="True" IsFilterable="False" IsGroupable="False" IsSortable="True" Width="100" UniqueName="RunDate" Header="Birth Date"  TextAlignment="Left"  DataFormatString=" {0:mm/dd/yyyy} "/>
-Arun

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Oct 2011, 07:06 AM
Hi Arun,

The correct syntax will be as follows:
- DataFormatString = "{0: MM/dd/yyyy}
You can also define it as:
- DataFormatString = "{0: MM:dd:yyyy}, DataFormatString = "{0: MM-dd-yyyy}
But it depends on how you want the date to be displayed. 
Please take a look at this article for any further reference on formatting a string. As you can see "m" is used for displaying minutes, while "M" is for months.
 

All the best,
Maya
the Telerik team

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

0
Arun
Top achievements
Rank 1
answered on 03 Oct 2011, 05:59 PM
<telerik:GridViewDataColumn DataType="{x:Null}" IsReadOnly="True" IsVisible="True" IsFilterable="False" IsGroupable="False" IsSortable="True" Width="100" UniqueName="RunDate" Header="Birth Date"  TextAlignment="Left"  DataFormatString=" {0:MM/dd/yyyy} "/>

Hello,

Now I changed into MM/dd/yyyy instead of mm/dd/yyyy and it is working fine. Thank you.

I have one more question. Based on the Regional setting date format  we are displaying the different date format in the Grid.

US regional setting - MM/DD/YYYY
UK regional setting - DD/MM/YYYY

In the previous version of Telerik we don't have to mention the Date format in the Xaml for Gridview. 

In the 2011 version, how do I set this date format based on setting. Can you please give me an example?

Thanks
Tags
GridView
Asked by
Arun
Top achievements
Rank 1
Answers by
Maya
Telerik team
Arun
Top achievements
Rank 1
Share this question
or