フィルターのクリア

How to select rows with NaT values ?

17 ビュー (過去 30 日間)
Namrata Goswami
Namrata Goswami 2021 年 1 月 27 日
コメント済み: Namrata Goswami 2021 年 1 月 29 日
I have a table:
ID StartDate EndDate
12 10/01/2021 12/01/2021
12 19/01/2021 NaT
12 03/01/2021 13/01/2021
12 09/01/2021 NaT
12 10/01/2021 14/01/2021
I'm trying to remove the rows with StartDate <= 10/01/2021 and EndDate == NaT
And the removed rows should go into a new table.
I have tried the following code, but it doesn't work.
NewTable = Table(Table.StartDate <= "10/01/2021" && EndDate == NaT,:);
Also, how to remove the rows meeting these conditions from the original table?
Thanks!

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 27 日
NewTable = Table(Table.StartDate <= datetime(2021,01,10) & isnat(EndDate),:);
or if you are okay with removing all NaT including cases where the StartDate does not match that criteria, then
NewTable = rmmissing(Table)
  1 件のコメント
Namrata Goswami
Namrata Goswami 2021 年 1 月 29 日
Thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by