calculating time difference from two string dates

조회 수: 1 (최근 30일)
Meh
Meh 2013년 2월 22일
편집: Tunechi 2015년 8월 12일
I have string dates say (05.01.1993 17:40:00) and (07.01.1993 09:50:00) is there a way to calculate the number of months/days/hours between these two dates?

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 22일
date1=datenum(1993,5,1)
date2=datenum(1993,7,1)
v=datestr(datenum(date1:date2))
n=numel(v) %number of days
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 22일
%-------Number of days--------
date1=datenum(1993,5,1)
date2=datenum(1993,7,1)
v=datestr(datenum(date1:date2))
n=numel(v) %number of days
%-------Number of minutes--------
d2=('09:50:00')
d1=('17:40:00')
minut=hour(d2)*60+minute(d2)-(hour(d1)*60+minute(d1))
Result=n*24*60+minut
Tunechi
Tunechi 2015년 8월 12일
편집: Tunechi 2015년 8월 12일
I think numel is not counting the number of days instead I used length(v)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile 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