フィルターのクリア

Convert data table to datetime

112 ビュー (過去 30 日間)
Raphael Willi
Raphael Willi 2021 年 5 月 5 日
コメント済み: Raphael Willi 2021 年 5 月 6 日
I have data shown in the image.
I want to convert the second row into a datetime vector, but InputFormat doesn't work.
It's a number, e.g. 201401010000 meaning jan 1st 2014 00:00.
I tried datetime( BLA,'InputFormat','yyyyMMddHHmm')

採用された回答

Adam Danz
Adam Danz 2021 年 5 月 5 日
編集済み: Adam Danz 2021 年 5 月 6 日
> It's a number, e.g. 201401010000 meaning jan 1st 2014 00:00.
x = 201401010000;
dt = datetime(string(x),'InputFormat','yyyyMMddHHmm')
dt = datetime
01-Jan-2014
The 'format' property specifies the output format.
x can be a column of values.
  3 件のコメント
Adam Danz
Adam Danz 2021 年 5 月 6 日
> I want to convert the second row into a datetime vector
> I would like to e.g. convert it to a timetable
Those are two very different questions.
I've updated my answer. After converting the column to datetime use
Raphael Willi
Raphael Willi 2021 年 5 月 6 日
Aha, I got it now thanks. I did it with
TT = table2timetable(data(:,3),'RowTimes',datetime(string(data{:,2}),'InputFormat','yyyyMMddHHmm'));

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by