Transform into a Matlab datetime format, Part 2 (Sample File Attached)

I have a column of MM_DD_YY and another column with hours (1 to 24). What is the best way to concatenate two entries to apply datetime? Thank you.

2 件のコメント

dpb
dpb 2018 年 6 月 14 日
Again, make it easier for folks to help...supply a short snippet of actual data so
  1. Know precisely how you have it, and
  2. Don't have to make something to hopefully match but can use what is provided directly.
dpb
dpb 2018 年 6 月 14 日
Attached file shows why precisely; the TITLE for the date column says MM_DD_YY but that is not how the data are stored; they're mm/dd/yyyy instead so a solution to the original question wouldn't work.
Point being not to criticize but to improve chances of getting correct answers without a lot of back-and-forth by supplying needed info up front. Remember we know only what you tell or show us; we can't see your terminal and we don't know what you've done so far...

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

 採用された回答

Star Strider
Star Strider 2018 年 6 月 14 日

0 投票

Try this:
TestTbl = readtable('Test.csv');
DT = datetime(TestTbl{:,1}, 'InputFormat','MM/dd/yyyy', 'Format','MM/dd/yyyy HH:mm');
DT = DT + hours(TestTbl{:,2})
DT =
2×1 datetime array
12/01/2017 01:00
12/01/2017 02:00

2 件のコメント

alpedhuez
alpedhuez 2018 年 6 月 14 日
Thank you.
Star Strider
Star Strider 2018 年 6 月 15 日
As always, my pleasure.

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

その他の回答 (0 件)

カテゴリ

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

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by