0

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 !

Kiran Reddy
  • 1,055
  • 3
  • 12
  • 19

2 Answers2

1

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"

Vok
  • 457
  • 5
  • 19
  • Thanks for your reply ! i used this cell format : like objPreview.dataGridView1.Columns["Date"].DefaultCellStyle.Format = "d"; But it is showing with date and time. – Kiran Reddy Jun 25 '12 at 11:51
1

I think this is a format issue. If your binding then use a string format of "MM-dd-yyyy" (assuming USA date formatting). Do a google for ".net custom date format". I think you will find that the XAML binding has a 'StringFormat' (or similar) option.

Best of luck

Rob

Rob Smyth
  • 1,768
  • 11
  • 19