Convert excel format to C# TimeStamp like excel do so -


in app i'm reading data excel sheet , stucked in moment when want timestamp cell. in speciffic cell got value '1900-01-02 13:20:04' , in excel using format '[h]:mm:ss' formats value '61:20:04', correct beacuse cells showing hours worked employees. want achieve read data excel in same format it's formated in excel('61:20:04') , save string. problem how read this, or convert timestamp value ?

edit.(the way doing now)

i reading code excel using odbc select data need(like sql select) -> add data datatable , i'm doing

dr["workedhours"].tostring() -(dr = datarow in datatable.rows) line returns '1900-01-02 13:20:04'. how can convert time excel does.

some proof of concept:

var timestamp = "1900-01-02 13:20:04"; var date = datetime.parse(timestamp); var stamp = date.subtract(new datetime(1900, 1, 1)); var result = string.format("{0}:{1:00}:{2:00}", 24 + stamp.days * 24 + stamp.hours, stamp.minutes, stamp.seconds); 

it seems reason excel takes time stamps 0 january 1900, why add 24 in hours result.

i assumed want format hh:mm:ss, days, month, etc.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -