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 cert开发者_如何学Goain 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
You can format Date in Gridview...
<asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:dd/MM/yyyy}" />
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();
精彩评论