String to Date Subtraction
Afficher commentaires plus anciens
Hello,
How do I subtract two dates that are in a string formatted like: 'Mon Feb 27 17:03:15 EST 2017' and 'Mon Feb 27 17:40:11 EST 2017' in matlab 2010a?
Réponse acceptée
Plus de réponses (1)
Peter Perkins
le 28 Fév 2017
Walter's datetime suggestion returns a duration, which represents an exact, fixed-length amount of time. Depending on what you mean by "subtract", you might also look at between to get the difference in terms of calendar units:
>> times = datetime([2016 2017],[11 2],[19 27],[14 17],[53 40],[20 0])
times =
1×2 datetime array
19-Nov-2016 14:53:20 27-Feb-2017 17:40:00
>> between(times(1),times(2))
ans =
calendarDuration
3mo 8d 2h 46m 40s
>> between(times(1),times(2),'weeks')
ans =
calendarDuration
14w
1 commentaire
Walter Roberson
le 28 Fév 2017
Note, though, that these operations require R2013b or later.
Catégories
En savoir plus sur Calendar dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!