开发者

How to save date in Excel in date format

开发者 https://www.devze.com 2023-01-30 01:31 出处:网络
I am working on the winforms. I want to save the date from datetimepicker in (dd/mm/yyyy ) format to the EXCEL sheet. I managed to save date as 10/10/2010 inone of the cells of excel sheet.

I am working on the winforms.

I want to save the date from datetimepicker in (dd/mm/yyyy ) format to the EXCEL sheet. I managed to save date as 10/10/2010 in one of the cells of excel sheet.

But when i m trying to read that value from excel sheet into the string what i get is,

string dateString ="40461";

what i was expecting is ,

string dateString ="10/10/2010";

Is it possible to convert this string (40461)into the format (10/10/2010) and to display as default time in datetimepicker on开发者_如何学运维 form load.

I even tried manually changing format of cell of the excel but didn't work for me. any help regarding this issue ? Thanx in advance.


Try this...

double dateDouble = 40461;  
DateTime dt = DateTime.FromOADate(dateDouble);

string dateString = dt.ToString();
0

精彩评论

暂无评论...
验证码 换一张
取 消