Calculate the date difference

4 ビュー (過去 30 日間)
Doaa Alamoudi
Doaa Alamoudi 2020 年 8 月 10 日
コメント済み: Star Strider 2020 年 8 月 10 日
I have two columns StartDate and Endate the value of the columns is 'datetime'
EndDate=[ '05-Aug-2020 00:00:00'
'05-Aug-2020 00:00:00'
'07-Aug-2020 00:00:00'
'07-Aug-2020 00:00:00'
'07-Aug-2020 00:00:00'
'01-Aug-2020 00:00:00']
Start Date= ['29-Jul-2020 00:00:00'
'29-Jul-2020 00:00:00'
'31-Jul-2020 00:00:00'
'31-Jul-2020 00:00:00'
'02-Aug-2020 00:00:00'
'01-Aug-2020 00:00:00'
'02-Aug-2020 00:00:00'
'29-Jul-2020 00:00:00'
'29-Jul-2020 00:00:00']
I would like to calculate the number of days per row in the column.
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 8 月 10 日
The number of day between what and what?
You appear to have a different number of EndDate than StartDate so a simple subtraction and calling days() does not appear to be what you would want to do.

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

採用された回答

Star Strider
Star Strider 2020 年 8 月 10 日
The vectors must have the same sizes.
Use between:
DaysDiff = between(StartDate(1:numel(EndDate)),EndDate)
to get:
DaysDiff =
6×1 calendarDuration array
7d
7d
7d
7d
5d
0d
.
  2 件のコメント
Doaa Alamoudi
Doaa Alamoudi 2020 年 8 月 10 日
Thanks That works with me
Star Strider
Star Strider 2020 年 8 月 10 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by