Borrar filtros
Borrar filtros

calculating time difference from two string dates

1 visualización (últimos 30 días)
Meh
Meh el 22 de Feb. de 2013
Editada: Tunechi el 12 de Ag. de 2015
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?

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 22 de Feb. de 2013
date1=datenum(1993,5,1)
date2=datenum(1993,7,1)
v=datestr(datenum(date1:date2))
n=numel(v) %number of days
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 22 de Feb. de 2013
%-------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 el 12 de Ag. de 2015
Editada: Tunechi el 12 de Ag. de 2015
I think numel is not counting the number of days instead I used length(v)

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by