Kiran Reddy
Kiran Reddy

Reputation: 1125

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 !

Upvotes: 0

Views: 646

Answers (2)

Vok
Vok

Reputation: 467

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"

Upvotes: 1

Rob Smyth
Rob Smyth

Reputation: 1858

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

Upvotes: 1

Related Questions