Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been facing problem while upload data from excel file to datagrid view.
Excel contain column's as

name
contact no
address
father's name
from place
to place
time
date
when ever data get load in datagrid view the time column shows data like "30-12-1899 PM 12:20:00"

but actual data is PM 12:20:00 and i dont why this date "30-12-1899" is came up time????

Help me to sort out this problem???
Posted

I suspect the database that you use to load your gridview have a datatype datetime for time field .If so,get only part from the time field in gridview that you want in your excel.

CSS
<asp:BoundField DataField="date1" HeaderText="Date Of Leave" SortExpression="date"
                            DataFormatString="{0:dd/MM/yy}" />


DataFormatString examples:
{0:dd MMMM yyyy} - gives 24 February 2006
{0:MMM dd}-gives Feb 24 (substitue MMM with MMMM for the full month name instead of abbreviation)
{0:dd/MM/yy}-gives 24/02/06
{0:dd/MM/yyyy}-gives 24/02/2006

You can have look at this link for further reference on how to use dataformatstrings.
 
Share this answer
 
v3
Change ur Date and time column format in Excel

Examble
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900