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

GridViewDateTimeColumn: Need Date without Time

2 Answers 1060 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Gone2TheDogs asked on 09 Nov 2016, 12:39 PM

I have a GridViewDateTimeColumn that I am trying to format to show only the date in the format:  "MM/dd/yyyy", but instead I get the time in the form of all zeros following the date. (see screen shot).

Property Settings:

Format:  Custom

FormatInfo: en-IN

CustomFormat:  MM/dd/yyyy

EditorType:  DateTimePicker

FilteringMode: Date

Is it possible to get rid of the time and just display the date? If so, how?

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Nov 2016, 01:37 PM
Hello Bob,

Thank you for writing.  

You can find below a sample code snippet demonstrating how to setup the GridViewDateTimeColumn and specify the format for the cells and the editor itself:
public RadForm1()
{
    InitializeComponent();
    GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn("Date");
    this.radGridView1.Columns.Add(dateTimeColumn);
 
    dateTimeColumn.FormatString = "{0:MM/dd/yyyy}"; // specify cell's format
 
    dateTimeColumn.Format = DateTimePickerFormat.Custom;//specify the editor's format
    dateTimeColumn.CustomFormat = "MM/dd/yyyy";
     
    this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
    for (int i = 0; i < 10; i++)
    {
        this.radGridView1.Rows.Add(DateTime.Now.AddDays(i));
    }
}

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
answered on 09 Nov 2016, 03:37 PM

Thanks Dess. Thank you for the quick reply!  I looked everywhere!

Tags
GridView
Asked by
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Share this question
or