Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm importing an excel file to asp.net and i'm filling it into a grid view...

i have a column for time in the excel sheet i'm inserting the following format "hh:mm" but i keep getting the full format in the asp.net

example: 11:11 in excel i get in asp.net 12/30/1899 11:11:00 AM although the format of the cell in excel is h:mm

i'm trying to change the value in the datatable but it's not working... how can i solve this?
VB
timee = row("TIME_TO_SEND")
finalTime = timee.Substring(0, 5)
row("TIME_TO_SEND")="hh:mm"


note that the convert of the date is working... but my problem is that in the datatable the format of the date is complete... so when i'm filling the grid view with the datatable i'm getting in the time column:12/30/1899 11:11:00 AM
Posted
Updated 8-Oct-13 22:57pm
v2

Try the below code. Variable "timee" should be string -

C#
timee =Convert.ToDatetime(row("TIME_TO_SEND")).ToString("hh:mm");
 
Share this answer
 
v2
Comments
Jocelyne El Khoury 9-Oct-13 4:51am    
the convert of the date is working... but my problem is that in the datatable the format of the date is complete... so when i'm filling the grid view with the datatable i'm getting in the time column:12/30/1899 11:11:00 AM
try the given below example -

<asp:BoundField DataField="Date" DataFormatString="{0:hh:mm}" HeaderStyle-HorizontalAlign="Left" HeaderText="Date" ItemStyle-HorizontalAlign="Left" />
 
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