Change data type of a table column into datetime?

Hi,
I have read a table with readtable and changed my the column with the time data to a char using detectImportOptions-function.
I now wanna change the data type from char to datetime but it doesnt work. How do i need to do it?

回答 (2 件)

Eric Sofen
Eric Sofen 2020 年 6 月 9 日

1 投票

Take a look at the convertvars function for changing the data type of a table variable.
Also, is there a reason you're bring in the time data as char rather than directly as datetime or duration from readtable?
Drishti Jain
Drishti Jain 2020 年 5 月 28 日

0 投票

e.g-
tm='10:14:25'
new_tm= datetime(tm,'Format','HH:mm:ss')

1 件のコメント

Mohammad Zaheer Hussein Suhabuth
Mohammad Zaheer Hussein Suhabuth 2022 年 10 月 21 日
How abou the whole column of the table?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Tables についてさらに検索

質問済み:

2020 年 5 月 27 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by