Search code examples
c#exceldatagridviewdatagridviewcolumn

Excel sheet cell dispalying Date and time using c#


I am importing Excel sheet into DataGridView.I have one of the cell has date as 05-06-2017.But while dispalyig under DataGridView it is showing 05-06-2017 AM 12:00:00.

Can you please help me how can i display only Date.

Thanks !


Solution

  • You will need to format the DateTime object DateTime Formats

    d.Format("d")
    

    Alternatively, set the format on the gridview column itself using the DefaultCellStyle.Format property with a parameter of "d"