Pod Mays
Pod Mays

Reputation: 2593

Time gets included when importing Date Cells from Excel to ASP SQL DB

I'm importing an Excel file to SQL through ASP.NET and a certain column includes dates (2/31/2000) with a cell format of (*d/mm/yyyy).

When I import the Excel file in ASP.NET, the data suddenly becomes like this in the gridview

2/31/200 12:00:00 AM

Upvotes: 2

Views: 1309

Answers (2)

Michael Christensen
Michael Christensen

Reputation: 1786

You didn't really ask a question. Is this after a round trip from uploading through asp.net storing in SQL server and then retrieving from DB and displaying in gridview? .net uses the datetime type If you want to display only the date portion you can use

DateTime exceldate = new DateTime();
exceldate.ToShortDateString();

Upvotes: 1

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

You can format Date in Gridview...

<asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:dd/MM/yyyy}" />

Upvotes: 2

Related Questions